Class: LaunchdTools::PathContent

Inherits:
Object
  • Object
show all
Defined in:
lib/launchd_tools/path_content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathContent

Returns a new instance of PathContent.



4
5
6
# File 'lib/launchd_tools/path_content.rb', line 4

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/launchd_tools/path_content.rb', line 3

def path
  @path
end

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/launchd_tools/path_content.rb', line 16

def binary?
  f = File.open(path, "r")
  f.read(6) == "bplist"
ensure
  f.close if f
end

#to_sObject



8
9
10
11
12
13
14
# File 'lib/launchd_tools/path_content.rb', line 8

def to_s
  if binary?
    `plutil -convert xml1 -o /dev/stdout '#{path}'`
  else
    File.read(path)
  end
end