Module: Vis::Utilities
- Defined in:
- lib/vis/utilities.rb
Defined Under Namespace
Modules: Native
Class Method Summary collapse
Instance Method Summary collapse
- #hash_array_to_native(array) ⇒ Object
- #lower_camelize(snake_cased_word) ⇒ Object
- #lower_camelize_hash(hash) ⇒ Object
- #native_to_hash_array(array) ⇒ Object
Class Method Details
Instance Method Details
#hash_array_to_native(array) ⇒ Object
25 26 27 |
# File 'lib/vis/utilities.rb', line 25 def hash_array_to_native(array) array.map(&:to_n) end |
#lower_camelize(snake_cased_word) ⇒ Object
33 34 35 36 37 |
# File 'lib/vis/utilities.rb', line 33 def lower_camelize(snake_cased_word) words = snake_cased_word.split('_') result = [words.first] result.concat(words[1..-1].map {|word| word[0].upcase + word[1..-1] }).join('') end |
#lower_camelize_hash(hash) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/vis/utilities.rb', line 39 def lower_camelize_hash(hash) camel_hash = {} hash.each do |key, value| value = lower_camelize_hash(value) if `Opal.is_a(value, Opal.Hash)` camel_hash[lower_camelize(key)] = value end camel_hash end |
#native_to_hash_array(array) ⇒ Object
29 30 31 |
# File 'lib/vis/utilities.rb', line 29 def native_to_hash_array(array) array.map { |i| `Opal.Hash.$new(i)` } end |