Class: Gembox::GemList
- Inherits:
-
Array
- Object
- Array
- Gembox::GemList
- Defined in:
- lib/gembox/gem_list.rb
Instance Method Summary collapse
Instance Method Details
#[](*args) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/gembox/gem_list.rb', line 5 def [](*args) if args.first.is_a?(String) search(args.first) else super end end |
#[]=(key, value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gembox/gem_list.rb', line 13 def []=(key, value) if key.is_a?(String) if versions = search(key) versions.replace([key, value]) else self << [key, value] end else super end end |
#has_key?(key) ⇒ Boolean
36 37 38 |
# File 'lib/gembox/gem_list.rb', line 36 def has_key?(key) !search(key).nil? end |
#search(key) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gembox/gem_list.rb', line 25 def search(key) i = find {|v| if v.is_a?(Array) v[0] == key else v == key end } i.is_a?(Array) ? i[1] : i end |