Class: NudgeType::IntType

Inherits:
Object
  • Object
show all
Extended by:
TypeBehaviors
Defined in:
lib/interpreter/types/pushTypes.rb

Class Method Summary collapse

Methods included from TypeBehaviors

any_value, extended, from_s, random_value, recognizes?, to_nudgecode

Class Method Details

.any_value(options = {}) ⇒ Object



70
71
72
# File 'lib/interpreter/types/pushTypes.rb', line 70

def self.any_value(options ={})
  self.random_value(options)
end

.defaultHighestObject



51
52
53
# File 'lib/interpreter/types/pushTypes.rb', line 51

def self.defaultHighest
  @defaultHighest
end

.defaultLowestObject



47
48
49
# File 'lib/interpreter/types/pushTypes.rb', line 47

def self.defaultLowest
  @defaultLowest
end

.from_s(string_value) ⇒ Object



62
63
64
# File 'lib/interpreter/types/pushTypes.rb', line 62

def self.from_s(string_value)
  return string_value.to_i
end

.random_value(params = {}) ⇒ Object



55
56
57
58
59
60
# File 'lib/interpreter/types/pushTypes.rb', line 55

def self.random_value(params={})
  bottom = params[:randomIntegerLowerBound] || @defaultLowest
  top = params[:randomIntegerUpperBound] || @defaultHighest
  lowest, highest = [bottom,top].min, [bottom,top].max
  rand(highest-lowest).to_i + lowest
end

.recognizes?(a_thing) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/interpreter/types/pushTypes.rb', line 66

def self.recognizes?(a_thing)
  !a_thing.kind_of?(String) && !a_thing.nil? && a_thing.respond_to?(:to_i)
end