Class: Dayvan::View
- Inherits:
-
Object
- Object
- Dayvan::View
- Defined in:
- lib/dayvan/view.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(path) ⇒ View
constructor
A new instance of View.
- #name ⇒ Object
- #src ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(path) ⇒ View
Returns a new instance of View.
17 18 19 |
# File 'lib/dayvan/view.rb', line 17 def initialize(path) self.path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/dayvan/view.rb', line 4 def path @path end |
Class Method Details
Instance Method Details
#compile ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dayvan/view.rb', line 29 def compile parse_tree = CoffeeScript::Parser.new.parse(src) ['map', 'reduce'].inject({}) do |memo, type| # Finds tops level assignemnts whose bound variable is map/reduce. assignment_node = parse_tree.children.find {|node| node.is_a?(CoffeeScript::AssignNode) && node.variable.base == type } if assignment_node memo[type] = assignment_node.value.compile(:indent => '') end memo end end |
#name ⇒ Object
21 22 23 |
# File 'lib/dayvan/view.rb', line 21 def name File.basename(path, '.*') end |
#src ⇒ Object
25 26 27 |
# File 'lib/dayvan/view.rb', line 25 def src File.read(path) end |
#to_json ⇒ Object
45 46 47 |
# File 'lib/dayvan/view.rb', line 45 def to_json compile.to_json end |