Class: PolyrexSchema
- Inherits:
-
Object
- Object
- PolyrexSchema
- Defined in:
- lib/polyrex-schema.rb
Instance Attribute Summary collapse
-
#to_schema ⇒ Object
readonly
Returns the value of attribute to_schema.
Instance Method Summary collapse
-
#initialize(s = nil) ⇒ PolyrexSchema
constructor
A new instance of PolyrexSchema.
- #parse(s) ⇒ Object
- #to_a ⇒ Object
- #to_doc ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(s = nil) ⇒ PolyrexSchema
Returns a new instance of PolyrexSchema.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/polyrex-schema.rb', line 11 def initialize(s=nil) if s then s.prepend 'root/' if s[0] == '{' r = add_node split(s) r[3] << node('recordx_type', 'polyrex') << node('schema',s) @doc = Rexle.new(r) end end |
Instance Attribute Details
#to_schema ⇒ Object (readonly)
Returns the value of attribute to_schema.
9 10 11 |
# File 'lib/polyrex-schema.rb', line 9 def to_schema @to_schema end |
Instance Method Details
#parse(s) ⇒ Object
23 24 25 26 27 |
# File 'lib/polyrex-schema.rb', line 23 def parse(s) doc = Rexle.new s @to_schema = scan_to_schema doc.root self end |
#to_a ⇒ Object
29 |
# File 'lib/polyrex-schema.rb', line 29 def to_a() scan_to_a(@doc.root.xpath 'records/.') end |
#to_doc ⇒ Object
31 |
# File 'lib/polyrex-schema.rb', line 31 def to_doc() @doc end |
#to_h ⇒ Object
30 |
# File 'lib/polyrex-schema.rb', line 30 def to_h() scan_to_h(@doc.root.xpath 'records/.') end |
#to_s ⇒ Object
32 |
# File 'lib/polyrex-schema.rb', line 32 def to_s() @doc.to_s end |