Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/sandwich/ext/string.rb

Instance Method Summary collapse

Instance Method Details

#super_to_iObject



2
# File 'lib/sandwich/ext/string.rb', line 2

alias_method :super_to_i, :to_i

#super_underscoreObject



3
# File 'lib/sandwich/ext/string.rb', line 3

alias_method :super_underscore, :underscore

#times(&block) ⇒ Object



17
18
19
# File 'lib/sandwich/ext/string.rb', line 17

def times(&block)
  to_i.times(&block)
end

#to_i(*args) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/sandwich/ext/string.rb', line 5

def to_i(*args)
  case self
  when "a", "the", "an" then 1
  when "no" then 0
  else super_to_i(*args)
  end
end

#underscoreObject



13
14
15
# File 'lib/sandwich/ext/string.rb', line 13

def underscore
  super_underscore.gsub(/ +/, "_")
end