Class: P4ApiVersion
Overview
This captures the version information of the P4API C++ library we're building against. This is mostly parsed into this structure and then spit out into a header file we compile into the Ruby API.
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patchlevel ⇒ Object
Returns the value of attribute patchlevel.
-
#suppdate ⇒ Object
Returns the value of attribute suppdate.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(major, minor = nil) ⇒ P4ApiVersion
constructor
A new instance of P4ApiVersion.
- #set_type(type) ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(major, minor = nil) ⇒ P4ApiVersion
Returns a new instance of P4ApiVersion.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'ext/P4/extconf.rb', line 298 def initialize(major, minor = nil) if (major.kind_of?(String) && !minor) if (major =~ /(\d+)\.(\d+)/) major = $1 minor = $2 else raise("Bad API version: #{major}") end end @major = major.to_i @minor = minor.to_i @type = nil @patchlevel = nil @suppdate = nil end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
323 324 325 |
# File 'ext/P4/extconf.rb', line 323 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
323 324 325 |
# File 'ext/P4/extconf.rb', line 323 def minor @minor end |
#patchlevel ⇒ Object
Returns the value of attribute patchlevel.
322 323 324 |
# File 'ext/P4/extconf.rb', line 322 def patchlevel @patchlevel end |
#suppdate ⇒ Object
Returns the value of attribute suppdate.
322 323 324 |
# File 'ext/P4/extconf.rb', line 322 def suppdate @suppdate end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
323 324 325 |
# File 'ext/P4/extconf.rb', line 323 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
339 340 341 342 343 344 |
# File 'ext/P4/extconf.rb', line 339 def <=>(other) hi = @major <=> other.major lo = @minor <=> other.minor return hi == 0 ? lo : hi end |
#set_type(type) ⇒ Object
316 317 318 319 320 |
# File 'ext/P4/extconf.rb', line 316 def set_type(type) if (type.kind_of?(String)) @type = type end end |
#to_i ⇒ Object
335 336 337 |
# File 'ext/P4/extconf.rb', line 335 def to_i major << 8 | minor end |
#to_s ⇒ Object
327 328 329 330 331 332 333 |
# File 'ext/P4/extconf.rb', line 327 def to_s if (@type and not @type.empty?) "#{major}.#{minor}.#{@type.upcase}" else "#{major}.#{minor}" end end |