Sha256: 320e4b88cd830d272ff9ab21ef3c3e9cef038046e6b632863368d0db47f8e8bf

Contents?: true

Size: 796 Bytes

Versions: 16

Compression:

Stored size: 796 Bytes

Contents

require File.dirname(__FILE__) + "/util"

class String
  def starts_with?(other)
    head = self[0, other.length]
    head == other
  end
end

module FN
  class Resource
    include Util
    attr_reader :node
    
    def initialize(node)
      raise_unless_xml_node node
      @node = node
    end
    
    def complete?
      !@node.children.empty?
    end
    
    def manual?
      !!@node["manual"]
    end
    
    def path=(p)
      @node.children.each{|c| c.remove! }
      @node << p.to_s
    end
    
    def path
      @node.first? && @node.first.to_s
    end
    
    def path_from(root)
      File.expand_path("#{root}#{path}")
    end
     
    def key
      @node["id"]
    end
    
    def type
      @node["type"]
    end
    
    def delete
      @node.remove!
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fn_document-0.9.18 lib/fn/resource.rb
fn_document-0.9.17 lib/fn/resource.rb
fn_document-0.9.16 lib/fn/resource.rb
fn_document-0.9.15 lib/fn/resource.rb
fn_document-0.9.14 lib/fn/resource.rb
fn_document-0.9.13 lib/fn/resource.rb
fn_document-0.9.12 lib/fn/resource.rb
fn_document-0.9.11 lib/fn/resource.rb
fn_document-0.9.10 lib/fn/resource.rb
fn_document-0.9.9 lib/fn/resource.rb
fn_document-0.9.8 lib/fn/resource.rb
fn_document-0.9.7 lib/fn/resource.rb
fn_document-0.9.6 lib/fn/resource.rb
fn_document-0.9.4 lib/fn/resource.rb
fn_document-0.9.3 lib/fn/resource.rb
fn_document-0.9.2 lib/fn/resource.rb