Class: BitClust::Subcommands::ChmCommand::Sitemap::Content

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, Enumerable
Defined in:
lib/bitclust/subcommands/chm_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, local = nil) ⇒ Content

Returns a new instance of Content.


76
77
78
79
80
# File 'lib/bitclust/subcommands/chm_command.rb', line 76

def initialize(name, local = nil)
  @name = name
  @local = local
  @contents = []
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents


81
82
83
# File 'lib/bitclust/subcommands/chm_command.rb', line 81

def contents
  @contents
end

#localObject (readonly)

Returns the value of attribute local


81
82
83
# File 'lib/bitclust/subcommands/chm_command.rb', line 81

def local
  @local
end

#nameObject (readonly)

Returns the value of attribute name


81
82
83
# File 'lib/bitclust/subcommands/chm_command.rb', line 81

def name
  @name
end

Instance Method Details

#<<(content) ⇒ Object


87
88
89
# File 'lib/bitclust/subcommands/chm_command.rb', line 87

def <<(content)
  @contents << content
end

#<=>(other) ⇒ Object


91
92
93
# File 'lib/bitclust/subcommands/chm_command.rb', line 91

def <=>(other)
  @name <=> other.name
end

#[](index) ⇒ Object


83
84
85
# File 'lib/bitclust/subcommands/chm_command.rb', line 83

def [](index)
  @contents[index]
end

#eachObject


95
96
97
98
99
# File 'lib/bitclust/subcommands/chm_command.rb', line 95

def each
  @contents.each do |content|
    yield content
  end
end

#to_htmlObject


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/bitclust/subcommands/chm_command.rb', line 101

def to_html
  str = "<LI> <OBJECT type=\"text/sitemap\">\n"
  str << "        <param name=\"Name\" value=\"<%=h @name%>\">\n"
  if @local
    str << "        <param name=\"Local\" value=\"<%[email protected]%>\">\n"
  end
  str << "        </OBJECT>\n"
  unless contents.empty?
    str << "<UL>\n"
    @contents.each do |content|
      str << content.to_html
    end
    str << "</UL>\n"
  end
  ERB.new(str).result(binding)
end