Parent

Class/Module Index [+]

Quicksearch

HammerCLI::Output::Dsl

Public Class Methods

new(options={}) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 5
def initialize(options={})
  @current_path = options[:path] || []
end

Public Instance Methods

build(&block) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 14
def build(&block)
  self.instance_eval &block
end
fields() click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 9
def fields
  @fields ||= []
  @fields
end

Protected Instance Methods

collection(key, label, options={}, &block) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 46
def collection(key, label, options={}, &block)
  field key, label, Fields::Collection, options, &block
end
current_path() click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 51
def current_path
  @current_path ||= []
  @current_path
end
custom_field(type, options={}, &block) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 29
def custom_field(type, options={}, &block)
  self.fields << type.new(options, &block)
end
field(key, label, type=nil, options={}, &block) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 20
def field(key, label, type=nil, options={}, &block)
  options[:path] = current_path.clone
  options[:path] << key if !key.nil?

  options[:label] = label
  type ||= Fields::Field
  custom_field type, options, &block
end
from(key) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 40
def from(key)
  self.current_path.push key
  yield if block_given?
  self.current_path.pop
end
label(label, &block) click to toggle source
# File lib/hammer_cli/output/dsl.rb, line 33
def label(label, &block)
  options = {}
  options[:path] = current_path.clone
  options[:label] = label
  custom_field Fields::Label, options, &block
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.