Class: Fields::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli/output/fields.rb

Direct Known Subclasses

Boolean, ContainerField, Date, Id, KeyValue, List, LongText

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Field

Returns a new instance of Field.



10
11
12
13
14
15
16
# File 'lib/hammer_cli/output/fields.rb', line 10

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]
  @options = options
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/hammer_cli/output/fields.rb', line 7

def label
  @label
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/hammer_cli/output/fields.rb', line 8

def path
  @path
end

Instance Method Details

#display?(value) ⇒ Boolean

Returns:



26
27
28
29
30
31
32
33
34
# File 'lib/hammer_cli/output/fields.rb', line 26

def display?(value)
  if value.is_a?(HammerCLI::Output::DataMissing)
    !hide_missing?
  elsif value.nil?
    !hide_blank?
  else
    true
  end
end

#hide_blank?Boolean

Returns:



18
19
20
# File 'lib/hammer_cli/output/fields.rb', line 18

def hide_blank?
  @hide_blank
end

#hide_missing?Boolean

Returns:



22
23
24
# File 'lib/hammer_cli/output/fields.rb', line 22

def hide_missing?
  @hide_missing
end

#parametersObject



36
37
38
# File 'lib/hammer_cli/output/fields.rb', line 36

def parameters
  @options
end