Module: Ruby::Node::Source
- Included in:
- Ruby::Node
- Defined in:
- lib/ruby/node/source.rb
Instance Method Summary collapse
- #context(options = {}) ⇒ Object
- #filename ⇒ Object
- #line ⇒ Object
- #lines ⇒ Object
- #src(prolog = false) ⇒ Object
Instance Method Details
#context(options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/ruby/node/source.rb', line 22 def context( = {}) filter = .has_key?(:highlight) ? [:highlight] : false line = filter ? self.line.head + filter.highlight(to_ruby) + self.line.tail : nil Ruby::Node::Text::Context.new(lines, row, [:width] || 2, line).to_s end |
#filename ⇒ Object
6 7 8 |
# File 'lib/ruby/node/source.rb', line 6 def filename root? ? @filename : root.filename end |
#line ⇒ Object
18 19 20 |
# File 'lib/ruby/node/source.rb', line 18 def line Ruby::Node::Text.new(lines[row]).clip([0, column], length) end |
#lines ⇒ Object
14 15 16 |
# File 'lib/ruby/node/source.rb', line 14 def lines root.src.split("\n") end |
#src(prolog = false) ⇒ Object
10 11 12 |
# File 'lib/ruby/node/source.rb', line 10 def src(prolog = false) root? ? @src : Ruby::Node::Text.new(root.src).clip(position(prolog), length(prolog)).to_s end |