module RuboCop::SketchUp::SketchUpTargetRange
Mix-in module for Cops that are valid only for a given SketchUp
version range. This mix-in uses the configured target SketchUp
version to determine if it's relevant.
Public Class Methods
included(mod)
click to toggle source
# File lib/rubocop/sketchup/sketchup_target_range.rb, line 34 def self.included(mod) mod.extend(ClassMethods) end
Public Instance Methods
sketchup_target_max_version()
click to toggle source
# File lib/rubocop/sketchup/sketchup_target_range.rb, line 42 def sketchup_target_max_version self.class.sketchup_target_max_version end
sketchup_target_min_version()
click to toggle source
# File lib/rubocop/sketchup/sketchup_target_range.rb, line 38 def sketchup_target_min_version self.class.sketchup_target_min_version end
valid_for_target_sketchup_version?()
click to toggle source
# File lib/rubocop/sketchup/sketchup_target_range.rb, line 46 def valid_for_target_sketchup_version? # If no target version is configured, ignore this check. return true unless sketchup_target_version? # If no version is set - then it's valid for all known versions. unless sketchup_target_min_version || sketchup_target_max_version return true end # If there is a finite version range, check if the target SketchUp # version is withing that. if sketchup_target_min_version && sketchup_target_max_version range = (sketchup_target_min_version..sketchup_target_max_version) return range.include?(sketchup_target_version) end if sketchup_target_min_version return sketchup_target_version >= sketchup_target_min_version end if sketchup_target_max_version return sketchup_target_version <= sketchup_target_max_version end raise 'bug!' # Should not end up here. end