Class: MarkdownExpander::Expander::Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown-expander.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Expression

Returns a new instance of Expression.



84
85
86
# File 'lib/markdown-expander.rb', line 84

def initialize value
  @value = value
end

Instance Method Details

#evaluate(scope) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/markdown-expander.rb', line 87

def evaluate scope
  parts = @value.split(".")
  current_scope = scope
  parts.each do |part|
    current_scope = current_scope[part.to_sym]
  end
  current_scope
end