Module: Baldr::Grammar

Defined in:
lib/baldr/grammar.rb

Defined Under Namespace

Modules: Envelope, Transaction, Version4010

Class Method Summary collapse

Class Method Details

.for_standard_version(version) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/baldr/grammar.rb', line 3

def self.for_standard_version(version)
  const_name = case version.length
    when 4
      "Version#{version}"
    when 5
      "Version#{version[2..4]}0"
    when 6
      "Version#{version[2..5]}"
    else
      nil
  end
  
  if const_name.present? && self.const_defined?(const_name)
    self.const_get(const_name)
  else    
    raise Baldr::Error, "unknown standard version number: #{version}"
  end
end