Class: Sheetah::Messaging::Messenger
- Inherits:
-
Object
- Object
- Sheetah::Messaging::Messenger
- Defined in:
- lib/sheetah/messaging.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#scope_data ⇒ Object
readonly
Returns the value of attribute scope_data.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #dup ⇒ Object
- #error(code, data = nil) ⇒ Object
- #exception(error) ⇒ Object
-
#initialize(scope: SCOPES::SHEET, scope_data: nil) ⇒ Messenger
constructor
A new instance of Messenger.
- #scope_col ⇒ Object
- #scope_col!(col, &block) ⇒ Object
- #scope_row ⇒ Object
- #scope_row!(row, &block) ⇒ Object
- #scoping ⇒ Object
- #scoping!(scope, scope_data, &block) ⇒ Object
- #warn(code, data = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
79 80 81 |
# File 'lib/sheetah/messaging.rb', line 79 def @messages end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
79 80 81 |
# File 'lib/sheetah/messaging.rb', line 79 def scope @scope end |
#scope_data ⇒ Object (readonly)
Returns the value of attribute scope_data.
79 80 81 |
# File 'lib/sheetah/messaging.rb', line 79 def scope_data @scope_data end |
Instance Method Details
#==(other) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/sheetah/messaging.rb', line 81 def ==(other) other.is_a?(self.class) && scope == other.scope && scope_data == other.scope_data && == other. end |
#dup ⇒ Object
88 89 90 91 92 93 |
# File 'lib/sheetah/messaging.rb', line 88 def dup self.class.new( scope: @scope, scope_data: @scope_data ) end |
#error(code, data = nil) ⇒ Object
150 151 152 |
# File 'lib/sheetah/messaging.rb', line 150 def error(code, data = nil) add(SEVERITIES::ERROR, code, data) end |
#exception(error) ⇒ Object
154 155 156 |
# File 'lib/sheetah/messaging.rb', line 154 def exception(error) error(error.msg_code) end |
#scope_col ⇒ Object
142 143 144 |
# File 'lib/sheetah/messaging.rb', line 142 def scope_col(...) dup.scope_col!(...) end |
#scope_col!(col, &block) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/sheetah/messaging.rb', line 124 def scope_col!(col, &block) scope = case @scope when SCOPES::ROW, SCOPES::CELL SCOPES::CELL else SCOPES::COL end scope_data = @scope_data.dup || {} scope_data[:col] = col scoping!(scope, scope_data, &block) end |
#scope_row ⇒ Object
138 139 140 |
# File 'lib/sheetah/messaging.rb', line 138 def scope_row(...) dup.scope_row!(...) end |
#scope_row!(row, &block) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sheetah/messaging.rb', line 110 def scope_row!(row, &block) scope = case @scope when SCOPES::COL, SCOPES::CELL SCOPES::CELL else SCOPES::ROW end scope_data = @scope_data.dup || {} scope_data[:row] = row scoping!(scope, scope_data, &block) end |
#scoping ⇒ Object
106 107 108 |
# File 'lib/sheetah/messaging.rb', line 106 def scoping(...) dup.scoping!(...) end |
#scoping!(scope, scope_data, &block) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/sheetah/messaging.rb', line 95 def scoping!(scope, scope_data, &block) scope = scope.freeze scope_data = scope_data.freeze if block replace_scoping_block(scope, scope_data, &block) else replace_scoping_noblock(scope, scope_data) end end |
#warn(code, data = nil) ⇒ Object
146 147 148 |
# File 'lib/sheetah/messaging.rb', line 146 def warn(code, data = nil) add(SEVERITIES::WARN, code, data) end |