Class: CodeInclusion::Subset::LineNumber

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#inputObject (readonly)

Returns the value of attribute input.



440
441
442
# File 'lib/polytexnic/code_inclusion.rb', line 440

def input
  @input
end

#numbersObject (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

#linesObject



446
447
448
# File 'lib/polytexnic/code_inclusion.rb', line 446

def lines
  individual_numbers.collect {|i| input[i - 1]}.compact
end