Module: Nokogiri::Decorators::XBEL::Entry

Included in:
Bookmark, Folder
Defined in:
lib/nokogiri/decorators/xbel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info


36
37
38
# File 'lib/nokogiri/decorators/xbel.rb', line 36

def info
  @info
end

Instance Method Details

#addedObject

Returns addition date.


79
80
81
# File 'lib/nokogiri/decorators/xbel.rb', line 79

def added
  if value = attribute('added') then Date.parse value.content end
end

#added=(value) ⇒ Object

Sets addition date.


83
84
85
86
87
88
89
90
# File 'lib/nokogiri/decorators/xbel.rb', line 83

def added=(value)
  set_attribute 'added', case value
  when Time; value.strftime '%Y-%m-%d'
  when String; value
  else
    raise ArgumentError
  end
end

#attributes=(attributes) ⇒ Object


38
39
40
# File 'lib/nokogiri/decorators/xbel.rb', line 38

def attributes=(attributes)
  attributes.each { |key, value| send "#{ key }=", value }
end

#descObject Also known as: description

Returns description of node.


43
44
45
# File 'lib/nokogiri/decorators/xbel.rb', line 43

def desc
  if node = at('./desc') then node.content end
end

#desc=(value) ⇒ Object Also known as: description=

Sets description of node.


47
48
49
50
51
52
# File 'lib/nokogiri/decorators/xbel.rb', line 47

def desc=(value)
  node = at './desc'
  node ||= add_child Nokogiri::XML::Node.new('desc', document)

  node.content = value
end

#idObject

Returns id for node.


70
71
72
# File 'lib/nokogiri/decorators/xbel.rb', line 70

def id
  if id = attribute('id') then id.content end
end

#id=(value) ⇒ Object

Sets id for node.


74
75
76
# File 'lib/nokogiri/decorators/xbel.rb', line 74

def id=(value)
  set_attribute 'id', value.to_s
end

#initialize_decoratorObject


27
28
29
30
31
32
33
34
35
# File 'lib/nokogiri/decorators/xbel.rb', line 27

def initialize_decorator
  @info = Hash.new do |info, owner|
    if String === owner
      info[owner] = at "./info/metadata[@owner='#{owner}']"
    else
      info[owner.to_s]
    end
  end
end

#titleObject Also known as: to_s

Returns title fo node.


57
58
59
# File 'lib/nokogiri/decorators/xbel.rb', line 57

def title
  if node = at('./title') then node.content end
end

#title=(value) ⇒ Object

Sets title for node.


61
62
63
64
65
66
# File 'lib/nokogiri/decorators/xbel.rb', line 61

def title=(value)
  node = at './title'
  node ||= add_child Nokogiri::XML::Node.new('title', document)

  node.content = value
end