Module: Zm::Client::Utils
- Defined in:
- lib/zm/client/common/utils.rb
Constant Summary collapse
- A_ARRAY_PROC =
->(i) { i.last.is_a?(Array) ? i.last.map { |j| [i.first, j] } : [i] }
- A_NODE_PROC =
->(n) { { n: n.first, _content: n.last } }
- ARROW =
'@'- EQUALS =
'='
Class Method Summary collapse
-
.arrow_name(name) ⇒ Object
TODO: chercher - remplacer toutes les occurrences dans le code.
- .arrow_name_sym(name) ⇒ Object
- .equals_name(name) ⇒ Object
- .format_email(email) ⇒ Object
- .map_format(array, klass, method_name) ⇒ Object
Class Method Details
.arrow_name(name) ⇒ Object
TODO: chercher - remplacer toutes les occurrences dans le code
19 20 21 22 23 |
# File 'lib/zm/client/common/utils.rb', line 19 def arrow_name(name) return name if name.to_s.start_with?(ARROW) "#{ARROW}#{name}" end |
.arrow_name_sym(name) ⇒ Object
25 26 27 |
# File 'lib/zm/client/common/utils.rb', line 25 def arrow_name_sym(name) arrow_name(name).to_sym end |
.equals_name(name) ⇒ Object
29 30 31 32 33 |
# File 'lib/zm/client/common/utils.rb', line 29 def equals_name(name) return name if name.to_s.end_with?(EQUALS) "#{name}#{EQUALS}" end |
.format_email(email) ⇒ Object
12 13 14 15 16 |
# File 'lib/zm/client/common/utils.rb', line 12 def format_email(email) email.strip! email.downcase! email end |
.map_format(array, klass, method_name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zm/client/common/utils.rb', line 35 def map_format(array, klass, method_name) array.map! do |item| if item.is_a?(klass) item elsif item.respond_to?(method_name) item.name end end array.compact! array end |