Class: RubyCF::Data

Inherits:
Object show all
Defined in:
lib/rubycf_extensions.rb

Overview

CF handles raw data different from strings. Ruby treats them the same. use RubyCF::Data objects to tell the plist encoder to treat the objects as data.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Data

Returns a new instance of Data.



24
25
26
# File 'lib/rubycf_extensions.rb', line 24

def initialize string
  self.data = string
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



18
19
20
# File 'lib/rubycf_extensions.rb', line 18

def data
  @data
end

Class Method Details

.from_file(file) ⇒ Object



20
21
22
# File 'lib/rubycf_extensions.rb', line 20

def self.from_file file
  Data.new(file.is_a?(File) ? file.read : File.read(file))
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/rubycf_extensions.rb', line 32

def == other
  if(other.is_a?(RubyCF::Data))
    return other.data == @data
  else
    return other == @data
  end
end

#inspectObject



28
29
30
# File 'lib/rubycf_extensions.rb', line 28

def inspect
  "RubyCF::Data #{@data.size} bytes"
end