Class: PolyrexSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrex-schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_schemaObject (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_aObject



29
# File 'lib/polyrex-schema.rb', line 29

def to_a()    scan_to_a(@doc.root.xpath 'records/.')  end

#to_docObject



31
# File 'lib/polyrex-schema.rb', line 31

def to_doc()  @doc                                    end

#to_hObject



30
# File 'lib/polyrex-schema.rb', line 30

def to_h()    scan_to_h(@doc.root.xpath 'records/.')  end

#to_sObject



32
# File 'lib/polyrex-schema.rb', line 32

def to_s()    @doc.to_s                               end