lib/ronin/arch.rb in ronin-0.0.9 vs lib/ronin/arch.rb in ronin-0.1.0
- old
+ new
@@ -39,20 +39,27 @@
property :endian, String
# Address length of the architecture
property :address_length, Integer
+ # Validates
+ validates_present :name, :endian, :address_length
+ validates_is_unique :name
+ validates_format :endian, :with => lambda { |endian|
+ endian == 'big' || endian == 'little'
+ }
+ validates_is_number :address_length
+
#
# Returns the name of the arch as a String.
#
def to_s
@name.to_s
end
#
# Defines a new builtin Arch with the specified _name_ and the given
- # _opts_. If _block_ is given, it will be passed the newly created
- # Arch.
+ # _options_.
#
def Arch.define(name,options={})
name = name.to_s
endian = options[:endian].to_s
address_length = options[:address_length].to_i