Class: CodeInclusion::Subset::LineNumber
- Inherits:
-
Object
- Object
- CodeInclusion::Subset::LineNumber
- Defined in:
- lib/polytexnic/code_inclusion.rb
Overview
Return the lines specified by :line_numbers. Line numbers are comma separated and may contain ranges, i.e.,
2, 4-6, 8, 14
Rules:
whitespace is ignored
ranges are included in ascending order (4-6 is the same as 6-4)
lines numbers higher than the max available are ignored
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#numbers ⇒ Object
readonly
Returns the value of attribute numbers.
Instance Method Summary collapse
-
#initialize(input, args) ⇒ LineNumber
constructor
A new instance of LineNumber.
- #lines ⇒ Object
Constructor Details
#initialize(input, args) ⇒ LineNumber
Returns a new instance of LineNumber.
441 442 443 444 |
# File 'lib/polytexnic/code_inclusion.rb', line 441 def initialize(input, args) @input = input @numbers = args[:line_numbers] end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
440 441 442 |
# File 'lib/polytexnic/code_inclusion.rb', line 440 def input @input end |
#numbers ⇒ Object (readonly)
Returns the value of attribute numbers.
440 441 442 |
# File 'lib/polytexnic/code_inclusion.rb', line 440 def numbers @numbers end |
Instance Method Details
#lines ⇒ Object
446 447 448 |
# File 'lib/polytexnic/code_inclusion.rb', line 446 def lines individual_numbers.collect {|i| input[i - 1]}.compact end |