Class: Sheng::WMLFile

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

Defined Under Namespace

Classes: InvalidWML

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, xml) ⇒ WMLFile

Returns a new instance of WMLFile.



7
8
9
10
11
# File 'lib/sheng/wml_file.rb', line 7

def initialize(filename, xml)
  @filename = filename
  @xml = Nokogiri::XML(xml)
  @errors = {}
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/sheng/wml_file.rb', line 5

def errors
  @errors
end

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/sheng/wml_file.rb', line 5

def filename
  @filename
end

#xmlObject (readonly)

Returns the value of attribute xml.



5
6
7
# File 'lib/sheng/wml_file.rb', line 5

def xml
  @xml
end

Instance Method Details

#interpolate(data_set) ⇒ Object



13
14
15
16
17
# File 'lib/sheng/wml_file.rb', line 13

def interpolate(data_set)
  parent_set.interpolate(data_set)
  errors.merge!(parent_set.errors)
  parent_set.xml_fragment.to_s
end

#parent_setObject



19
20
21
# File 'lib/sheng/wml_file.rb', line 19

def parent_set
  @parent_set ||= MergeFieldSet.new('main', xml)
end

#required_hashObject



23
24
25
# File 'lib/sheng/wml_file.rb', line 23

def required_hash
  parent_set.required_hash
end

#to_treeObject



27
28
29
# File 'lib/sheng/wml_file.rb', line 27

def to_tree
  parent_set.to_tree
end