Class: Cnab::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/cnab/definition.rb

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Definition

Returns a new instance of Definition.



3
4
5
6
7
8
9
10
11
12
# File 'lib/cnab/definition.rb', line 3

def initialize(version)
  raise Exceptions::VersionNotImplemented unless File.directory?("#{Cnab.lib_path}/cnab/versions/#{version}")

  @header_arquivo = Definitions::HeaderArquivo.new(version)
  @header_lote = Definitions::HeaderLote.new(version)
  @segmento_t = Definitions::SegmentoT.new(version)
  @segmento_u = Definitions::SegmentoU.new(version)
  @trailer_lote = Definitions::TrailerLote.new(version)
  @trailer_arquivo = Definitions::TrailerArquivo.new(version)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



14
15
16
17
# File 'lib/cnab/definition.rb', line 14

def method_missing(method_name)
  return instance_variable_get("@#{method_name}") if instance_variable_defined?("@#{method_name}")
  super
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean



19
20
21
22
# File 'lib/cnab/definition.rb', line 19

def respond_to_missing?(method_name, include_private = false)
  return true if instance_variable_defined?("@#{method_name}")
  super
end