Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/Helper.rb
Constant Summary collapse
- @@label_language =
:russian
Class Method Summary collapse
Instance Method Summary collapse
- #to_action ⇒ Object
- #to_each ⇒ Object
- #to_input ⇒ Object
- #to_label ⇒ Object
- #to_open_subpage ⇒ Object
- #to_params ⇒ Object
- #to_press_action ⇒ Object
- #to_select ⇒ Object
- #to_validator ⇒ Object
Class Method Details
.label_language ⇒ Object
20 21 22 |
# File 'lib/Helper.rb', line 20 def self.label_language @@label_language end |
.label_language=(l) ⇒ Object
14 15 16 17 18 |
# File 'lib/Helper.rb', line 14 def self.label_language=(l) raise ArgumentError, "unsupported language, supported languages: #{@supported_languages.inspect}\nmore: https://github.com/norman/babosa.git"\ unless @supported_languages.include? l @@label_language = l end |
Instance Method Details
#to_action ⇒ Object
32 33 34 |
# File 'lib/Helper.rb', line 32 def to_action 'fire_'+self.to_label end |
#to_each ⇒ Object
52 53 54 |
# File 'lib/Helper.rb', line 52 def to_each self.to_label+'_each' end |
#to_input ⇒ Object
40 41 42 |
# File 'lib/Helper.rb', line 40 def to_input 'feed_'+self.to_label end |
#to_label ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/Helper.rb', line 24 def to_label if String.label_language == :english return self.to_slug.to_ruby_method.downcase else return self.to_slug.transliterate(String.label_language).to_ruby_method.downcase end end |
#to_open_subpage ⇒ Object
56 57 58 |
# File 'lib/Helper.rb', line 56 def to_open_subpage self.to_label+'_open' end |
#to_params ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/Helper.rb', line 60 def to_params params = {} self.split(",").collect(&:strip).sort.each{|p| params[p.split("=")[0].strip.to_sym] = p.split("=")[1].strip } params end |
#to_press_action ⇒ Object
44 45 46 |
# File 'lib/Helper.rb', line 44 def to_press_action 'press_'+self.to_label end |
#to_select ⇒ Object
48 49 50 |
# File 'lib/Helper.rb', line 48 def to_select 'select_from_'+self.to_label end |
#to_validator ⇒ Object
36 37 38 |
# File 'lib/Helper.rb', line 36 def to_validator 'validate_'+self.to_label end |