Module: ObjectSugar::InstanceMethods
- Includes:
- Enumerable
- Defined in:
- lib/object_sugar/object_sugar.rb
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Iterate over each const name and value.
-
#find_by_name(name) ⇒ Object
Find Name.
-
#find_by_value(value) ⇒ Object
Find Value.
-
#names ⇒ Object
Names.
-
#values ⇒ Object
Values.
Instance Method Details
#each(&block) ⇒ Object
Iterate over each const name and value
167 168 169 |
# File 'lib/object_sugar/object_sugar.rb', line 167 def each(&block) constants.each { |c| yield(c, const_get(c)) } end |
#find_by_name(name) ⇒ Object
Find Name
188 189 190 |
# File 'lib/object_sugar/object_sugar.rb', line 188 def find_by_name(name) find { |k,_| k == name } end |
#find_by_value(value) ⇒ Object
Find Value
195 196 197 |
# File 'lib/object_sugar/object_sugar.rb', line 195 def find_by_value(value) find { |_,v| v == value } end |
#names ⇒ Object
Names
174 175 176 |
# File 'lib/object_sugar/object_sugar.rb', line 174 def names map(&:first) end |
#values ⇒ Object
Values
181 182 183 |
# File 'lib/object_sugar/object_sugar.rb', line 181 def values map(&:last) end |