Class: FlattenDB::Base
- Inherits:
-
Object
- Object
- FlattenDB::Base
- Defined in:
- lib/flattendb/base.rb
Constant Summary collapse
- BUILDER_OPTIONS =
{ :xml => { :indent => 2 } }
- ELEMENT_START =
%r{^[a-zA-Z_:]}- ELEMENT_CHARS =
%q{\w:.-}
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #flatten!(*args) ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #to_xml(*args) ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/flattendb/base.rb', line 75 def initialize() config = .select { |k, _| k.is_a?(String) } if config.size > 1 raise ArgumentError, "can't have more than one primary (root) table" end @root, @config = config.first @input, @output = .values_at(:input, :output) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
73 74 75 |
# File 'lib/flattendb/base.rb', line 73 def config @config end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
73 74 75 |
# File 'lib/flattendb/base.rb', line 73 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
73 74 75 |
# File 'lib/flattendb/base.rb', line 73 def output @output end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
73 74 75 |
# File 'lib/flattendb/base.rb', line 73 def root @root end |
Class Method Details
.[](type) ⇒ Object
61 62 63 |
# File 'lib/flattendb/base.rb', line 61 def [](type) types[type] end |
.to_flat!(*args) ⇒ Object
53 54 55 |
# File 'lib/flattendb/base.rb', line 53 def to_flat!(*args) new(*args).flatten!.to_xml end |
.types ⇒ Object
57 58 59 |
# File 'lib/flattendb/base.rb', line 57 def types Base.instance_variable_get(:@types) end |
Instance Method Details
#flatten!(*args) ⇒ Object
87 88 89 |
# File 'lib/flattendb/base.rb', line 87 def flatten!(*args) raise NotImplementedError, 'must be defined by sub-class' end |
#to_xml(*args) ⇒ Object
91 92 93 |
# File 'lib/flattendb/base.rb', line 91 def to_xml(*args) raise NotImplementedError, 'must be defined by sub-class' end |