Method: BasicVersion#initialize
- Defined in:
- lib/basic_version.rb
#initialize(*args) ⇒ BasicVersion
Returns a new instance of BasicVersion.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/basic_version.rb', line 7 def initialize(*args) if args.size == 1 && args.first.kind_of?(String) && md = StringRexp.match(args.first) args = md.captures.map { |a| a.to_i } end case args.size when 0 # no-op when 1 self.tiny = args.first.to_i when 3 self.major, self.minor, self.tiny = *args.map{|a| a.to_i } else raise ArgumentError end Fields.each_with_index do |f, i| next unless self.send(f).nil? self.send(:"#{f}=", 0) end end |