Class: Cell
- Inherits:
-
Object
- Object
- Cell
- Defined in:
- lib/spreadshit.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(raw = "", &expression) ⇒ Cell
constructor
A new instance of Cell.
- #update(value = raw || "", &expression) ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(raw = "", &expression) ⇒ Cell
Returns a new instance of Cell.
71 72 73 74 75 76 |
# File 'lib/spreadshit.rb', line 71 def initialize(raw = "", &expression) @raw = raw @observers = Set.new @observed = [] update(&expression) if block_given? end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
69 70 71 |
# File 'lib/spreadshit.rb', line 69 def raw @raw end |
Instance Method Details
#update(value = raw || "", &expression) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/spreadshit.rb', line 86 def update(value = raw || "", &expression) @raw = value @expression = expression compute @value end |
#value ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/spreadshit.rb', line 78 def value if @@caller @observers << @@caller @@caller.observed << self end @value end |