Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/Helper.rb

Constant Summary collapse

@@label_language =
:russian

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.label_languageObject


20
21
22
# File 'lib/Helper.rb', line 20

def self.label_language
  @@label_language
end

.label_language=(l) ⇒ Object

Raises:

  • (ArgumentError)

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_actionObject


32
33
34
# File 'lib/Helper.rb', line 32

def to_action
  'fire_'+self.to_label
end

#to_eachObject


52
53
54
# File 'lib/Helper.rb', line 52

def to_each
  self.to_label+'_each'
end

#to_inputObject


40
41
42
# File 'lib/Helper.rb', line 40

def to_input
  'feed_'+self.to_label
end

#to_labelObject


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_subpageObject


56
57
58
# File 'lib/Helper.rb', line 56

def to_open_subpage
  self.to_label+'_open'
end

#to_paramsObject


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_actionObject


44
45
46
# File 'lib/Helper.rb', line 44

def to_press_action
  'press_'+self.to_label
end

#to_selectObject


48
49
50
# File 'lib/Helper.rb', line 48

def to_select
  'select_from_'+self.to_label
end

#to_validatorObject


36
37
38
# File 'lib/Helper.rb', line 36

def to_validator
  'validate_'+self.to_label
end