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

Create a RubyCF::Data object from a string



48
49
50
# File 'lib/rubycf_extensions.rb', line 48

def initialize string
  self.data = string
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



40
41
42
# File 'lib/rubycf_extensions.rb', line 40

def data
  @data
end

Class Method Details

.from_file(file) ⇒ Object

Create a RubyCF::Data object from a file path or handle



43
44
45
# File 'lib/rubycf_extensions.rb', line 43

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

Instance Method Details

#==(other) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/rubycf_extensions.rb', line 56

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

#inspectObject



52
53
54
# File 'lib/rubycf_extensions.rb', line 52

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