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.
37 38 39 40 |
# File 'lib/expressir/express/visitor.rb', line 37 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
46 47 48 49 50 |
# File 'lib/expressir/express/visitor.rb', line 46 def method_missing(name, *args) rulename = name.to_s.sub(/^visit_/, "").gsub(/_([a-z])/) { |m| m[1].upcase }.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.
34 35 36 |
# File 'lib/expressir/express/visitor.rb', line 34 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/expressir/express/visitor.rb', line 34 def name @name end |
#source_pos ⇒ Object
Returns the value of attribute source_pos.
35 36 37 |
# File 'lib/expressir/express/visitor.rb', line 35 def source_pos @source_pos end |
Instance Method Details
#each(&block) ⇒ Object
60 61 62 |
# File 'lib/expressir/express/visitor.rb', line 60 def each(&block) @data.values.each(&block) end |
#keys ⇒ Object
52 53 54 |
# File 'lib/expressir/express/visitor.rb', line 52 def keys @data.keys end |
#text ⇒ Object
42 43 44 |
# File 'lib/expressir/express/visitor.rb', line 42 def text str.data.to_s end |
#values ⇒ Object
56 57 58 |
# File 'lib/expressir/express/visitor.rb', line 56 def values @data.values end |