Class: Rubyang::Database::SchemaTree::IntegerType

Inherits:
Type
  • Object
show all
Defined in:
lib/rubyang/database/schema_tree.rb

Instance Attribute Summary

Attributes inherited from Type

#arg

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ IntegerType

Returns a new instance of IntegerType.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rubyang/database/schema_tree.rb', line 68

def initialize arg
  @arg = arg
  range = case arg
          when 'int8'   then '-128..127'
          when 'int16'  then '-32768..32767'
          when 'int32'  then '-2147483648..2147483647'
          when 'int64'  then '-9223372036854775808..9223372036854775807'
          when 'uint8'  then '0..255'
          when 'uint16' then '0..65535'
          when 'uint32' then '0..4294967295'
          when 'uint64' then '0..18446744073709551615'
          end
  @range = Range.new range
end

Instance Method Details

#update_range(arg) ⇒ Object



82
83
84
# File 'lib/rubyang/database/schema_tree.rb', line 82

def update_range arg
  @range.update arg
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
89
# File 'lib/rubyang/database/schema_tree.rb', line 85

def valid? value
  result = true
  result &&= @range.valid? value
  result
end