Class: HtmlCom::Tabs
- Inherits:
-
Object
- Object
- HtmlCom::Tabs
- Defined in:
- lib/htmlcom.rb
Defined Under Namespace
Classes: Tab
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#tab ⇒ Object
readonly
Returns the value of attribute tab.
Instance Method Summary collapse
- #add_tab(title, content: '', index: nil) ⇒ Object
- #delete_tab(i) ⇒ Object
-
#initialize(type = :tabs, headings: [], xml: nil, debug: false) ⇒ Tabs
constructor
current options for type: :tabs, :full_page_tabs.
- #ping ⇒ Object (also: #refresh)
-
#to_bangtag ⇒ Object
not yet working properly.
- #to_css ⇒ Object
- #to_html ⇒ Object
- #to_js ⇒ Object
- #to_webpage ⇒ Object
Constructor Details
#initialize(type = :tabs, headings: [], xml: nil, debug: false) ⇒ Tabs
current options for type:
:tabs, :full_page_tabs
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/htmlcom.rb', line 172 def initialize(type=:tabs, headings: [], xml: nil, debug: false) @type, @debug = type, debug @build = JsMenuBuilder.new(type, headings: headings) @active_tab = 1 @tab = headings.map do |heading| Tab.new heading, content: "<h3>#{heading}</h3>", callback: self, debug: debug end if xml then @build.import(xml) end end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
167 168 169 |
# File 'lib/htmlcom.rb', line 167 def active @active end |
#tab ⇒ Object (readonly)
Returns the value of attribute tab.
167 168 169 |
# File 'lib/htmlcom.rb', line 167 def tab @tab end |
Instance Method Details
#add_tab(title, content: '', index: nil) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/htmlcom.rb', line 195 def add_tab(title, content: '', index: nil) tab = Tab.new(title, content: content) if index then @tab.insert index, tab else @tab << tab end refresh() end |
#delete_tab(i) ⇒ Object
209 210 211 212 |
# File 'lib/htmlcom.rb', line 209 def delete_tab(i) @tab.delete i refresh() end |
#ping ⇒ Object Also known as: refresh
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/htmlcom.rb', line 214 def ping() tabs = @tab.map do |tab| tab.title ? tab.to_a : nil end.compact.to_h if @debug then puts 'inside ping; tabs: ' + tabs.inspect puts '@active_tab: ' + @active_tab.inspect end @build = JsMenuBuilder.new(@type, tabs: tabs, active: @active_tab, debug: @debug) end |
#to_bangtag ⇒ Object
not yet working properly
245 246 247 248 |
# File 'lib/htmlcom.rb', line 245 def to_bangtag() XmlToSliml.new(@build.to_xml, spacer: '!')\ .to_s.lines.map {|x| '!' + x }.join end |
#to_css ⇒ Object
232 233 234 |
# File 'lib/htmlcom.rb', line 232 def to_css() @build.to_css end |
#to_html ⇒ Object
236 237 238 |
# File 'lib/htmlcom.rb', line 236 def to_html() @build.to_html end |
#to_js ⇒ Object
240 241 242 |
# File 'lib/htmlcom.rb', line 240 def to_js() @build.to_js end |
#to_webpage ⇒ Object
250 251 252 |
# File 'lib/htmlcom.rb', line 250 def to_webpage() @build.to_webpage end |