Class: SchemaReader::Table

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes) ⇒ Table

Returns a new instance of Table.



83
84
85
# File 'lib/schema_reader.rb', line 83

def initialize(name, attributes)
  @name, @attributes = name, attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



81
82
83
# File 'lib/schema_reader.rb', line 81

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



81
82
83
# File 'lib/schema_reader.rb', line 81

def name
  @name
end

Class Method Details

.parse(table_data) ⇒ Object



87
88
89
90
91
92
# File 'lib/schema_reader.rb', line 87

def self.parse(table_data)
  return unless name = table_data[/table "(.+)"/]
  name = $1
  atts = table_data.lines.to_a.select {|line| line =~ /t\.\w+/ }.map {|att| Attribute.parse att }
  Table.new(name, atts)
end