Class: Plistr::Value

Inherits:
Element show all
Defined in:
lib/plistr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Value

Returns a new instance of Value.



57
58
59
60
# File 'lib/plistr.rb', line 57

def initialize(name)
  @name = name
  @text = ""
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



55
56
57
# File 'lib/plistr.rb', line 55

def name
  @name
end

#textObject (readonly)

Returns the value of attribute text.



55
56
57
# File 'lib/plistr.rb', line 55

def text
  @text
end

Instance Method Details

#parseObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/plistr.rb', line 62

def parse
  case @name
  when "string"
    @text
  when "real"
    @text.to_f
  when "integer"
    @text.to_i
  when "date"
    DateTime.parse(@text)
  when "data"
    Base64.decode64(@text.gsub(/\s/, ''))
  when "key"
    @text
  end
end