class Fields::Field

Attributes

label[RW]
parent[RW]
path[R]
sets[W]

Public Class Methods

new(options={}) click to toggle source
# File lib/hammer_cli/output/fields.rb, line 9
def initialize(options={})
  @hide_blank = options[:hide_blank].nil? ? false : options[:hide_blank]
  @hide_missing = options[:hide_missing].nil? ? true : options[:hide_missing]
  @path = options[:path] || []
  @label = options[:label]
  @sets = options[:sets]
  @options = options
end

Public Instance Methods

display?(value) click to toggle source
# File lib/hammer_cli/output/fields.rb, line 43
def display?(value)
  if value.is_a?(HammerCLI::Output::DataMissing)
    !hide_missing?
  elsif value.nil?
    !hide_blank?
  else
    true
  end
end
full_label() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 34
def full_label
  return @label.to_s if @parent.nil?
  "#{@parent.full_label}/#{@label}"
end
hide_blank?() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 26
def hide_blank?
  @hide_blank
end
hide_missing?() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 30
def hide_missing?
  @hide_missing
end
id() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 18
def id
  @options[:id] || @options[:key] || @label
end
match_id?(field_id) click to toggle source
# File lib/hammer_cli/output/fields.rb, line 22
def match_id?(field_id)
  @options[:id] == field_id || @options[:key] == field_id || @label == _(field_id)
end
parameters() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 53
def parameters
  @options
end
sets() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 39
def sets
  @sets || inherited_sets || default_sets
end

Protected Instance Methods

default_sets() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 64
def default_sets
  %w[DEFAULT ALL]
end
inherited_sets() click to toggle source
# File lib/hammer_cli/output/fields.rb, line 59
def inherited_sets
  return nil if @parent.nil?
  @parent.sets
end