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
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#comments_hash_flag ⇒ Object
Returns the value of attribute comments_hash_flag.
-
#comments_range ⇒ Object
Returns the value of attribute comments_range.
-
#group ⇒ Object
deprecated
Deprecated.
Groups are now defined by directives
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #first_line ⇒ Object
-
#initialize(tokens, block = nil, comments = nil) ⇒ Statement
constructor
A new instance of Statement.
- #inspect ⇒ Object
-
#line ⇒ Fixnum
The first line of Ruby source.
-
#line_range ⇒ Range<Fixnum>
The first to last lines of Ruby source.
- #show ⇒ Object
- #to_s(include_block = true) ⇒ Object (also: #source)
Constructor Details
#initialize(tokens, block = nil, comments = nil) ⇒ Statement
Returns a new instance of Statement.
14 15 16 17 18 19 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 14 def initialize(tokens, block = nil, comments = nil) @tokens = tokens @block = block @comments = comments @comments_hash_flag = false end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5 def block @block end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
5 6 7 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5 def comments @comments end |
#comments_hash_flag ⇒ Object
Returns the value of attribute comments_hash_flag.
12 13 14 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 12 def comments_hash_flag @comments_hash_flag end |
#comments_range ⇒ Object
Returns the value of attribute comments_range.
6 7 8 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 6 def comments_range @comments_range end |
#group ⇒ Object
Deprecated.
Groups are now defined by directives
10 11 12 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 10 def group @group end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
5 6 7 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 5 def tokens @tokens end |
Instance Method Details
#first_line ⇒ Object
21 22 23 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 21 def first_line to_s.split(/\n/)[0] end |
#inspect ⇒ Object
32 33 34 35 36 37 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 32 def inspect l = line - 1 to_s(false).split(/\n/).map do |text| "\t#{l += 1}: #{text}" end.join("\n") end |
#line ⇒ Fixnum
Returns the first line of Ruby source.
44 45 46 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 44 def line tokens.first.line_no end |
#line_range ⇒ Range<Fixnum>
Returns the first to last lines of Ruby source.
50 51 52 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 50 def line_range tokens.first.line_no..tokens.last.line_no end |
#show ⇒ Object
39 40 41 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 39 def show "\t#{line}: #{first_line}" end |
#to_s(include_block = true) ⇒ Object Also known as: source
25 26 27 28 29 |
# File 'lib/yard/parser/ruby/legacy/statement.rb', line 25 def to_s(include_block = true) tokens.map do |token| RubyToken::TkBlockContents === token ? (include_block ? block.to_s : '') : token.text end.join end |