class HammerCLI::Help::TextBuilder
Attributes
definition[RW]
Public Class Methods
new(richtext = false)
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 8 def initialize(richtext = false) @richtext = richtext @definition = HammerCLI::Help::Definition.new end
Public Instance Methods
at(path = []) { |sub_builder| ... }
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 42 def at(path = []) item = path.empty? ? self : @definition.at(path) sub_builder = TextBuilder.new(@richtext) sub_builder.definition = item.definition yield(sub_builder) item.definition = sub_builder.definition end
find_item(item_id)
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 38 def find_item(item_id) @definition.find_item(item_id) end
indent(content, indentation = nil)
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 56 def indent(content, indentation = nil) HammerCLI::Help::AbstractItem.indent(content, indentation) end
insert(mode, item_id) { |sub_builder| ... }
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 50 def insert(mode, item_id) sub_builder = TextBuilder.new(@richtext) yield(sub_builder) @definition.insert_definition(mode, item_id, sub_builder.definition) end
list(items, options = {}, &block)
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 25 def list(items, options = {}, &block) return if items.empty? @definition << HammerCLI::Help::List.new(items, options, &block) end
note(content, options = {})
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 21 def note(content, options = {}) @definition << HammerCLI::Help::Note.new(content, options) end
section(label, options = {}) { |sub_builder| ... }
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 31 def section(label, options = {}, &block) sub_builder = TextBuilder.new(@richtext) yield(sub_builder) if block_given? options[:richtext] ||= @richtext @definition << HammerCLI::Help::Section.new(label, sub_builder.definition, options) end
string()
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 13 def string @definition.build_string end
text(content, options = {})
click to toggle source
# File lib/hammer_cli/help/text_builder.rb, line 17 def text(content, options = {}) @definition << HammerCLI::Help::Text.new(content, options) end