Class: RubyVM::AbstractSyntaxTree::NodeWrapper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- RubyVM::AbstractSyntaxTree::NodeWrapper
- Defined in:
- lib/solargraph/parser/rubyvm/node_wrapper.rb
Overview
Wrapper for RubyVM::AbstractSyntaxTree::Node. for return character based column
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
- #class ⇒ Object
- #first_column ⇒ Object
-
#initialize(node, code) ⇒ NodeWrapper
constructor
A new instance of NodeWrapper.
- #is_a?(type) ⇒ Boolean
- #last_column ⇒ Object
Constructor Details
#initialize(node, code) ⇒ NodeWrapper
Returns a new instance of NodeWrapper.
9 10 11 12 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 9 def initialize(node, code) @code = code super(node) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 6 def code @code end |
Class Method Details
.from(node, code) ⇒ Object
14 15 16 17 18 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 14 def self.from(node, code) return node unless node.is_a?(RubyVM::AbstractSyntaxTree::Node) and !node.kind_of?(SimpleDelegator) new(node, code) end |
Instance Method Details
#children ⇒ Object
43 44 45 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 43 def children @children ||= __getobj__.children.map do |node| NodeWrapper.from(node, @code) end end |
#class ⇒ Object
24 25 26 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 24 def class __getobj__.class end |
#first_column ⇒ Object
29 30 31 32 33 34 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 29 def first_column @first_column ||= begin line = @code[__getobj__.first_lineno - 1] || "" line.byteslice(0, __getobj__.first_column).length end end |
#is_a?(type) ⇒ Boolean
20 21 22 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 20 def is_a?(type) __getobj__.is_a?(type) || super.is_a?(type) end |
#last_column ⇒ Object
36 37 38 39 40 41 |
# File 'lib/solargraph/parser/rubyvm/node_wrapper.rb', line 36 def last_column @last_column ||= begin line = @code[__getobj__.last_lineno - 1] || "" line.byteslice(0, __getobj__.last_column).length end end |