Class: Mexico::FileSystem::Data

Inherits:
Object
  • Object
show all
Includes:
Poseidon, ROXML
Defined in:
lib/mexico/file_system/data.rb

Overview

the data container

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Data

TODO:

map and list types

keine Bool-Klasse in Ruby. xml_accessor :boolean_value, :as => Bool, :from => “B”



42
43
44
45
46
47
48
# File 'lib/mexico/file_system/data.rb', line 42

def initialize(args={})
  args.each do |k,v|
    if self.respond_to?("#{k}=")
      send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#documentObject

xml_accessor :list, :as => Mexico::FileSystem::FiestaList, :from => “List”



31
32
33
# File 'lib/mexico/file_system/data.rb', line 31

def document
  @document
end

#itemObject

xml_accessor :list, :as => Mexico::FileSystem::FiestaList, :from => “List”



31
32
33
# File 'lib/mexico/file_system/data.rb', line 31

def item
  @item
end

Instance Method Details

#after_parseObject



50
51
52
# File 'lib/mexico/file_system/data.rb', line 50

def after_parse
  # resolve links
end

#is_map?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/mexico/file_system/data.rb', line 92

def is_map?
  (string_value.nil? && !map_value.nil? && list_value.nil?)
end

#is_string?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/mexico/file_system/data.rb', line 88

def is_string?
  (!string_value.nil? && map_value.nil? && list_value.nil?)
end

#list_valueObject



60
61
62
63
# File 'lib/mexico/file_system/data.rb', line 60

def list_value
  # return nil unless @type=="list"
  @list # ||= JSON::load(@string_value)
end

#list_value=(val = Array.new) ⇒ Object



71
72
73
74
75
# File 'lib/mexico/file_system/data.rb', line 71

def list_value=(val=Array.new)
  @string_value = nil
  @map = nil
  @list = val
end

#map_valueObject



55
56
57
58
# File 'lib/mexico/file_system/data.rb', line 55

def map_value
  # return nil unless @type=="map"
  @map # ||= JSON::load(@string_value)
end

#map_value=(val) ⇒ Object



65
66
67
68
69
# File 'lib/mexico/file_system/data.rb', line 65

def map_value=(val)
  @string_value = nil
  @list = nil
  @map = Mexico::FileSystem::FiestaMap.new(val)
end

#string_value=(new_string) ⇒ Object



77
78
79
80
81
# File 'lib/mexico/file_system/data.rb', line 77

def string_value=(new_string)
  @map = nil
  @list = nil
  @string_value = new_string
end

#to_sObject



83
84
85
86
# File 'lib/mexico/file_system/data.rb', line 83

def to_s
  return string_value unless string_value.nil?
  return @map.to_s unless @map.nil?
end