Class: Daifuku::StrdefGenerator::StreamDefinition
- Inherits:
-
Object
- Object
- Daifuku::StrdefGenerator::StreamDefinition
- Includes:
- Enumerable
- Defined in:
- lib/daifuku/strdef_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #each_column(&block) ⇒ Object
-
#initialize(columns) ⇒ StreamDefinition
constructor
A new instance of StreamDefinition.
Constructor Details
#initialize(columns) ⇒ StreamDefinition
Returns a new instance of StreamDefinition.
26 27 28 |
# File 'lib/daifuku/strdef_generator.rb', line 26 def initialize(columns) @columns = columns end |
Class Method Details
.parse(strdef) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/daifuku/strdef_generator.rb', line 10 def self.parse(strdef) columns = {} strdef.each_line do |line| case line when /\A\s*-\s+(\w+):\s*(!domain\s+\w+|!\w+)(?:\s+(\d+))?/ name = $1 type = $2.sub(/\s+/, ' ').sub(/\A!/, '') length = $3 columns[name] = StreamColumn.new(name, type, length&.to_i) end end new(columns) end |
Instance Method Details
#[](name) ⇒ Object
34 35 36 |
# File 'lib/daifuku/strdef_generator.rb', line 34 def [](name) @columns[name] end |
#each_column(&block) ⇒ Object
30 31 32 |
# File 'lib/daifuku/strdef_generator.rb', line 30 def each_column(&block) @columns.each_value(&block) end |