Sha256: 0818cd31bde86550002befa419b2e27b6f780b14915a0a64876ca859ce5a78b7

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'set'


module Orchestrator
    module Constants
        On = true       # On is active
        Off = false     # Off is inactive
        Down = true     # Down is usually active (projector screen for instance)
        Up = false      # Up is usually inactive
        Open = true
        Close = false
        Short = false

        On_vars = Set.new([1, true, 'true', 'True', 
                            :on, :On, 'on', 'On', 
                            :yes, :Yes, 'yes', 'Yes', 
                            'down', 'Down', :down, :Down, 
                            'open', 'Open', :open, :Open])
        Off_vars = Set.new([0, false, 'false', 'False',
                            :off, :Off, 'off', 'Off', 
                            :no, :No, 'no', 'No',
                            'up', 'Up', :up, :Up,
                            'close', 'Close', :close, :Close,
                            'short', 'Short', :short, :Short])


        def in_range(num, max, min = 0)
            num = min if num < min
            num = max if num > max
            num
        end

        def is_affirmative?(val)
            On_vars.include?(val)
        end

        def is_negatory?(val)
            Off_vars.include?(val)
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
orchestrator-1.0.2 lib/orchestrator/utilities/constants.rb
orchestrator-1.0.1 lib/orchestrator/utilities/constants.rb