Class: YARD::Parser::Ruby::Legacy::Statement
- Inherits:
-
Object
- Object
- YARD::Parser::Ruby::Legacy::Statement
- Defined in:
- lib/yard/parser/ruby/legacy/statement.rb
Instance Attribute Summary (collapse)
-
- (Object) block
readonly
Returns the value of attribute block.
-
- (Object) comments
readonly
Returns the value of attribute comments.
-
- (Object) comments_range
Returns the value of attribute comments_range.
-
- (Object) group
Returns the value of attribute group.
-
- (Object) tokens
readonly
Returns the value of attribute tokens.
Instance Method Summary (collapse)
- - (Object) first_line
-
- (Statement) initialize(tokens, block = nil, comments = nil)
constructor
A new instance of Statement.
- - (Object) inspect
-
- (Fixnum) line
The first line of Ruby source.
-
- (Range<Fixnum>) line_range
The first to last lines of Ruby source.
- - (Object) show
- - (Object) to_s(include_block = true) (also: #source)
Constructor Details
- (Statement) initialize(tokens, block = nil, comments = nil)
A new instance of Statement
7 8 9 10 11 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 7 def initialize(tokens, block = nil, comments = nil) @tokens = tokens @block = block @comments = comments end |
Instance Attribute Details
- (Object) block (readonly)
Returns the value of attribute block
4 5 6 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 4 def block @block end |
- (Object) comments (readonly)
Returns the value of attribute comments
4 5 6 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 4 def comments @comments end |
- (Object) comments_range
Returns the value of attribute comments_range
5 6 7 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5 def comments_range @comments_range end |
- (Object) group
Returns the value of attribute group
5 6 7 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5 def group @group end |
- (Object) tokens (readonly)
Returns the value of attribute tokens
4 5 6 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 4 def tokens @tokens end |
Instance Method Details
- (Object) first_line
13 14 15 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 13 def first_line to_s.split(/\n/)[0] end |
- (Object) inspect
24 25 26 27 28 29 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 24 def inspect l = line - 1 to_s(false).split(/\n/).map do |text| "\t#{l += 1}: #{text}" end.join("\n") end |
- (Fixnum) line
The first line of Ruby source
36 37 38 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 36 def line tokens.first.line_no end |
- (Range<Fixnum>) line_range
The first to last lines of Ruby source
42 43 44 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 42 def line_range tokens.first.line_no..tokens.last.line_no end |
- (Object) show
31 32 33 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 31 def show "\t #{line}: #{first_line}" end |
- (Object) to_s(include_block = true) Also known as: source
17 18 19 20 21 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 17 def to_s(include_block = true) tokens.map do |token| RubyToken::TkBlockContents === token ? (include_block ? block.to_s : '') : token.text end.join end |