class Drupid::VersionCore
Represents the core attribute of a version object (e.g., ‘7.x’). A VersionCore
object can be initialized from a number, a string, a Drupid::VersionCore
object or a Drupid::Version
object.
Examples:
core = Drupid::VersionCore.new '8.x' core = Drupid::VersionCore.new '8' core = Drupid::VersionCore.new '8.x-1.0' core = Drupid::VersionCore.new 8 core = Drupid::VersionCore.new(Drupid::Version.new(8, '1.0'))
Attributes
core[R]
Public Class Methods
new(spec)
click to toggle source
# File lib/drupid/project_version.rb 42 def initialize spec 43 if spec.is_a?(String) 44 spec.strip.match(/^(\d+)(\.x)?($|-)/) 45 raise NotDrupalVersionError, "Wrong core specification: #{core}" unless $1 46 @core = $1.to_i 47 elsif spec.is_a?(Version) 48 @core = spec.core.to_i 49 elsif spec.is_a?(VersionCore) 50 @core = spec.to_i 51 elsif spec.is_a?(Numeric) 52 @core = spec.to_i # to_i truncates a Float object (so that 7.9 correctly becomes 7) 53 else 54 raise NotDrupalVersionError, "Wrong core specification: #{core}" 55 end 56 end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/drupid/project_version.rb 68 def <=>(other) 69 @core <=> other.core 70 end
to_i()
click to toggle source
Returns the core number as a Fixnum object.
# File lib/drupid/project_version.rb 64 def to_i 65 @core 66 end
to_s()
click to toggle source
Returns the core number as a string, e.g., ‘8.x’.
# File lib/drupid/project_version.rb 59 def to_s 60 @core.to_s + '.x' 61 end