Class: Fields::Field
- Inherits:
-
Object
show all
- Defined in:
- lib/hammer_cli/output/fields.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Field
Returns a new instance of Field.
9
10
11
12
13
14
15
16
|
# 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
|
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
7
8
9
|
# File 'lib/hammer_cli/output/fields.rb', line 7
def label
@label
end
|
#parent ⇒ Object
Returns the value of attribute parent.
7
8
9
|
# File 'lib/hammer_cli/output/fields.rb', line 7
def parent
@parent
end
|
#path ⇒ Object
Returns the value of attribute path.
5
6
7
|
# File 'lib/hammer_cli/output/fields.rb', line 5
def path
@path
end
|
#sets ⇒ Object
39
40
41
|
# File 'lib/hammer_cli/output/fields.rb', line 39
def sets
@sets || inherited_sets || default_sets
end
|
Instance Method Details
#display?(value) ⇒ Boolean
43
44
45
46
47
48
49
50
51
|
# 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 ⇒ Object
34
35
36
37
|
# 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? ⇒ Boolean
26
27
28
|
# File 'lib/hammer_cli/output/fields.rb', line 26
def hide_blank?
@hide_blank
end
|
#hide_missing? ⇒ Boolean
30
31
32
|
# File 'lib/hammer_cli/output/fields.rb', line 30
def hide_missing?
@hide_missing
end
|
#id ⇒ Object
18
19
20
|
# File 'lib/hammer_cli/output/fields.rb', line 18
def id
@options[:id] || @options[:key] || @label
end
|
#match_id?(field_id) ⇒ Boolean
22
23
24
|
# 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 ⇒ Object
53
54
55
|
# File 'lib/hammer_cli/output/fields.rb', line 53
def parameters
@options
end
|