Class: Apperol::AppJson::Env
- Inherits:
-
Object
- Object
- Apperol::AppJson::Env
- Defined in:
- lib/apperol/app_json.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #description ⇒ Object
- #has_value? ⇒ Boolean
-
#initialize(key, definition) ⇒ Env
constructor
A new instance of Env.
- #needs_value? ⇒ Boolean
- #required? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(key, definition) ⇒ Env
Returns a new instance of Env.
19 20 21 22 |
# File 'lib/apperol/app_json.rb', line 19 def initialize(key, definition) @key = key @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
18 19 20 |
# File 'lib/apperol/app_json.rb', line 18 def definition @definition end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
18 19 20 |
# File 'lib/apperol/app_json.rb', line 18 def key @key end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/apperol/app_json.rb', line 28 def description definition.is_a?(String) ? key : definition["description"] end |
#has_value? ⇒ Boolean
36 37 38 |
# File 'lib/apperol/app_json.rb', line 36 def has_value? !(value.nil? || value.strip.empty?) end |
#needs_value? ⇒ Boolean
32 33 34 |
# File 'lib/apperol/app_json.rb', line 32 def needs_value? required? && !has_value? end |
#required? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/apperol/app_json.rb', line 40 def required? definition.is_a?(String) || definition["required"].nil? || definition["required"] end |
#value ⇒ Object
24 25 26 |
# File 'lib/apperol/app_json.rb', line 24 def value definition.is_a?(String) ? definition : definition["value"] end |