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.



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

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

#localObject (readonly)

Returns the value of attribute local.



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

def local
  @local
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#<<(content) ⇒ Object



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

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

#<=>(other) ⇒ Object



94
95
96
# File 'lib/bitclust/subcommands/chm_command.rb', line 94

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

#[](index) ⇒ Object



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

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

#eachObject



98
99
100
101
102
# File 'lib/bitclust/subcommands/chm_command.rb', line 98

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

#to_htmlObject



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

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=\"<%=@local%>\">\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