Class: Sirens::ObjectBrowserModel::InstanceVariable
- Inherits:
-
Object
- Object
- Sirens::ObjectBrowserModel::InstanceVariable
- Defined in:
- lib/sirens/models/object_browser_model.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #display_string ⇒ Object
- #icon ⇒ Object
-
#initialize(key:, value:) ⇒ InstanceVariable
constructor
A new instance of InstanceVariable.
- #key_display_string ⇒ Object
- #value_display_string ⇒ Object
Constructor Details
#initialize(key:, value:) ⇒ InstanceVariable
Returns a new instance of InstanceVariable.
90 91 92 93 |
# File 'lib/sirens/models/object_browser_model.rb', line 90 def initialize(key:, value:) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
95 96 97 |
# File 'lib/sirens/models/object_browser_model.rb', line 95 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
95 96 97 |
# File 'lib/sirens/models/object_browser_model.rb', line 95 def value @value end |
Instance Method Details
#display_string ⇒ Object
101 102 103 104 105 |
# File 'lib/sirens/models/object_browser_model.rb', line 101 def display_string() return value_display_string if key.nil? "#{key_display_string} = #{value_display_string}" end |
#icon ⇒ Object
97 98 99 |
# File 'lib/sirens/models/object_browser_model.rb', line 97 def icon() Icons.icon_for(@value) end |
#key_display_string ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/sirens/models/object_browser_model.rb', line 107 def key_display_string() if key.kind_of?(Numeric) "[#{key}]" else key.to_s end end |
#value_display_string ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/sirens/models/object_browser_model.rb', line 115 def value_display_string() return "an Array(#{value.size})" if value.kind_of?(Array) return 'a Hash' if value.kind_of?(Hash) string = value.to_s if string.start_with?('#<') "a " + value.class.name else value.inspect end end |