Class: Cocoadex::Element

Inherits:
Object
  • Object
show all
Includes:
Bri::Templates::Helpers, Comparable
Defined in:
lib/cocoadex/models/element.rb

Overview

A searchable element stored in the cache

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Bri::Templates::Helpers

h3, inline_title, wrap

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/cocoadex/models/element.rb', line 8

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
# File 'lib/cocoadex/models/element.rb', line 21

def <=> other
  name <=> other.name if other.respond_to? :name
end

#originObject



25
26
27
# File 'lib/cocoadex/models/element.rb', line 25

def origin
  raise "#{self.class}#origin is not defined"
end

#parse_parameters(node) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/cocoadex/models/element.rb', line 33

def parse_parameters node
  node.css("dt").each do |param|
    name_nodes = param.css("em")
    if name_nodes.size > 0
      name = param.css("em").first.text
      description = param.next.css("p").first.text
      parameters << Parameter.new(name, description)
    end
  end
end


14
15
16
17
18
19
# File 'lib/cocoadex/models/element.rb', line 14

def print
  template_name = self.class.const_get("TEMPLATE_NAME")
  path = Cocoadex.view_path(template_name)
  template = IO.read(path, :mode => 'rb')
  ERB.new(template, nil, '<>').result(binding)
end

#to_sObject



10
11
12
# File 'lib/cocoadex/models/element.rb', line 10

def to_s
  name
end

#typeObject



29
30
31
# File 'lib/cocoadex/models/element.rb', line 29

def type
  raise "#{self.class}#type is not defined"
end