Module: Microscope::Utils

Defined in:
lib/microscope/utils.rb

Class Method Summary collapse

Class Method Details

.past_participle_to_infinitive(key) ⇒ Object

Convert a past participle to its infinitive form



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/microscope/utils.rb', line 4

def self.past_participle_to_infinitive(key)
  *key, participle = key.split('_')

  infinitive = participle

  if Microscope.special_verbs.include?(participle)
    infinitive = Microscope.special_verbs[participle]
  elsif participle =~ /ed$/
    infinitive = participle.sub(/d$/, '')
  end

  (key << infinitive).join('_')
end

.value_to_boolean(value) ⇒ Object

Convert a value to its boolean representation



19
20
21
# File 'lib/microscope/utils.rb', line 19

def self.value_to_boolean(value)
  ![nil, false, 0, '0', 'f', 'F', 'false', 'FALSE'].include?(value.presence)
end