Class: FN::Resource

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/fn/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#raise_unless_xml_doc, #raise_unless_xml_node

Constructor Details

#initialize(node) ⇒ Resource

Returns a new instance of Resource.



15
16
17
18
# File 'lib/fn/resource.rb', line 15

def initialize(node)
  raise_unless_xml_node node
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



13
14
15
# File 'lib/fn/resource.rb', line 13

def node
  @node
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


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

def complete?
  !@node.children.empty?
end

#deleteObject



49
50
51
# File 'lib/fn/resource.rb', line 49

def delete
  @node.remove!
end

#keyObject



41
42
43
# File 'lib/fn/resource.rb', line 41

def key
  @node["id"]
end

#manual?Boolean

Returns:

  • (Boolean)


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

def manual?
  !!@node["manual"]
end

#pathObject



33
34
35
# File 'lib/fn/resource.rb', line 33

def path
  @node.first? && @node.first.to_s
end

#path=(p) ⇒ Object



28
29
30
31
# File 'lib/fn/resource.rb', line 28

def path=(p)
  @node.children.each{|c| c.remove! }
  @node << p.to_s
end

#path_from(root) ⇒ Object



37
38
39
# File 'lib/fn/resource.rb', line 37

def path_from(root)
  File.expand_path("#{root}#{path}")
end

#typeObject



45
46
47
# File 'lib/fn/resource.rb', line 45

def type
  @node["type"]
end