Class: Spreadshit

Inherits:
Object
  • Object
show all
Defined in:
lib/spreadshit.rb,
lib/spreadshit/window.rb,
lib/spreadshit/version.rb

Defined Under Namespace

Classes: Cell, Formula, Functions, Window

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Constructor Details

#initialize(parser = Formula.new, functions = Functions.new) ⇒ Spreadshit

Returns a new instance of Spreadshit.



6
7
8
9
10
# File 'lib/spreadshit.rb', line 6

def initialize(parser = Formula.new, functions = Functions.new)
  @cells = Hash.new { |hash, key| hash[key] = Cell.new }
  @parser = parser
  @functions = functions
end

Instance Method Details

#[](address) ⇒ Object



12
13
14
# File 'lib/spreadshit.rb', line 12

def [](address)
  @cells[address.to_sym].value
end

#[]=(address, value) ⇒ Object



16
17
18
# File 'lib/spreadshit.rb', line 16

def []=(address, value)
  @cells[address.to_sym].update(value) { parse(value) }
end

#cell_at(address) ⇒ Object



20
21
22
# File 'lib/spreadshit.rb', line 20

def cell_at(address)
  @cells[address.to_sym]
end