Class: Expressir::Express::Visitor::Ctx
- Inherits:
-
Object
- Object
- Expressir::Express::Visitor::Ctx
- Defined in:
- lib/expressir/express/visitor.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_pos ⇒ Object
Returns the value of attribute source_pos.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(data, name) ⇒ Ctx
constructor
A new instance of Ctx.
- #keys ⇒ Object
- #method_missing(name, *args) ⇒ Object
- #text ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(data, name) ⇒ Ctx
Returns a new instance of Ctx.
34 35 36 37 |
# File 'lib/expressir/express/visitor.rb', line 34 def initialize(data, name) @data = data @name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/expressir/express/visitor.rb', line 43 def method_missing(name, *args) rulename = name.to_s.sub(/^visit_/, "").gsub(/_([a-z])/) do |m| m[1].upcase end.to_sym self.class.define_method(name) { @data[rulename] } send name, *args end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
31 32 33 |
# File 'lib/expressir/express/visitor.rb', line 31 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/expressir/express/visitor.rb', line 31 def name @name end |
#source_pos ⇒ Object
Returns the value of attribute source_pos.
32 33 34 |
# File 'lib/expressir/express/visitor.rb', line 32 def source_pos @source_pos end |
Instance Method Details
#each(&block) ⇒ Object
59 60 61 |
# File 'lib/expressir/express/visitor.rb', line 59 def each(&block) @data.values.each(&block) end |
#keys ⇒ Object
51 52 53 |
# File 'lib/expressir/express/visitor.rb', line 51 def keys @data.keys end |
#text ⇒ Object
39 40 41 |
# File 'lib/expressir/express/visitor.rb', line 39 def text str.data.to_s end |
#values ⇒ Object
55 56 57 |
# File 'lib/expressir/express/visitor.rb', line 55 def values @data.values end |