Class: XRay::JS::Element
Direct Known Subclasses
Expression, ForConditionElement, FunctionDeclaraion, Program, Statement
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #contains?(target) ⇒ Boolean
-
#initialize(type, left = nil, right = nil, position = nil) ⇒ Element
constructor
A new instance of Element.
- #position ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(type, left = nil, right = nil, position = nil) ⇒ Element
Returns a new instance of Element.
10 11 12 |
# File 'lib/js/struct.rb', line 10 def initialize(type, left = nil, right = nil, position = nil) @type, @left, @right, @position = type, left, right, position end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
8 9 10 |
# File 'lib/js/struct.rb', line 8 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
8 9 10 |
# File 'lib/js/struct.rb', line 8 def right @right end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/js/struct.rb', line 8 def type @type end |
Instance Method Details
#contains?(target) ⇒ Boolean
24 25 26 27 28 |
# File 'lib/js/struct.rb', line 24 def contains?(target) return true if target == @type left && left.respond_to?(:contains?) && left.contains?(target) or right && right.respond_to?(:contains?) && right.contains?(target) end |
#position ⇒ Object
18 19 20 21 22 |
# File 'lib/js/struct.rb', line 18 def position @position ? @position : left ? left.position : right ? right.position : nil end |
#text ⇒ Object
14 15 16 |
# File 'lib/js/struct.rb', line 14 def text "(#{type},#{left},#{right})" end |