Class: CodeInclusion::Listing

Inherits:
Object
  • Object
show all
Defined in:
lib/polytexnic/code_inclusion.rb

Overview

It contains factory methods to choose the correct FullListing and Subset classes and the code to wire them together. If you add new FullListing or Subset objects, you’ll need to wire them together here.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Listing

Returns a new instance of Listing.



226
227
228
# File 'lib/polytexnic/code_inclusion.rb', line 226

def initialize(args)
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



224
225
226
# File 'lib/polytexnic/code_inclusion.rb', line 224

def args
  @args
end

Class Method Details

.for(args) ⇒ Object

Returns the lines of code to be included or

an exception containing the error message.


220
221
222
# File 'lib/polytexnic/code_inclusion.rb', line 220

def self.for(args)
  new(args).final_listing
end

Instance Method Details

#final_listingObject



230
231
232
233
234
235
236
# File 'lib/polytexnic/code_inclusion.rb', line 230

def final_listing
  subset_class.new(full_listing, args).lines

  rescue SubsetException => e
    raise RetrievalException.new(e.message +
                                 " in file '#{args[:filename]}'")
end