class MakersToolbelt::CommandLine::GetPositiveNumber

Public Instance Methods

call() click to toggle source
Calls superclass method
# File lib/makers_toolbelt/command_line/questions/get_positive_number.rb, line 7
def call
  super.to_i
end

Private Instance Methods

is_greater_than_zero?(input) click to toggle source
# File lib/makers_toolbelt/command_line/questions/get_positive_number.rb, line 24
def is_greater_than_zero?(input)
  input.to_i > 0
end
is_number?(input) click to toggle source
# File lib/makers_toolbelt/command_line/questions/get_positive_number.rb, line 20
def is_number?(input)
  input.to_i.to_s == input
end
validate(input) click to toggle source
# File lib/makers_toolbelt/command_line/questions/get_positive_number.rb, line 13
def validate(input)
  unless is_number?(input) && is_greater_than_zero?(input)
    raise "You must enter a valid number" 
  end
  input
end