class RBT::SimpleVersionComparer

Constants

TO_COMPARE
#

TO_COMPARE

#

Attributes

be_extra_verbose[W]

Public Class Methods

new( to_compare = TO_COMPARE, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/simple_version_comparer.rb, line 33
def initialize(
    to_compare  = TO_COMPARE,
    run_already = true
  )
  reset
  scan_then_compare(to_compare) if run_already
end

Public Instance Methods

reset() click to toggle source
#

reset

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/simple_version_comparer.rb, line 44
def reset
  super()
  # ======================================================================= #
  # === @be_extra_verbose
  # ======================================================================= #
  @be_extra_verbose = false
  # ======================================================================= #
  # === @return_value
  # ======================================================================= #
  @return_value = false # defaults to false value.
end
return_value() click to toggle source
#

return_value

#
# File lib/rbt/utility_scripts/simple_version_comparer.rb, line 59
def return_value
  @return_value
end
run(i)
Alias for: scan_then_compare
scan_then_compare(i) click to toggle source
#

scan_then_compare

By convention, valid input to this method must include a ‘ ’.

This is needed so that we can split on it.

<=
<
>=
>
==
<>=

The last one means “smaller or larger than”, as in not equal to. So it is the same as !=.

#
# File lib/rbt/utility_scripts/simple_version_comparer.rb, line 79
def scan_then_compare(i) # run tag
  @string_to_compare = i
  a, operator, b = @string_to_compare.split ' '
  if i.include? '<>=' # Hack for now. Always true.
    @return_value = ! (a == b)
  elsif i.include? '!='
    @return_value = ! (a == b) # Same reason as above.
  else
    @return_value = Gem::Version.new(a).send(operator, Gem::Version.new(b))
  end
  if @be_extra_verbose
    e rev+
      '`'+('%15s' % @string_to_compare)+
      '` was: `'+('%3s' % operator.to_s)+ # Beautify the input here.
      '`. This is a '+steelblue(@return_value.to_s)+' statement.'
  end
  return @return_value
end
Also aliased as: run