class Origen::Mode
A class to handle the Origen
execution mode
Constants
- MODES
Public Class Methods
new(_options = {})
click to toggle source
# File lib/origen/mode.rb, line 6 def initialize(_options = {}) @current_mode = :production end
Public Instance Methods
==(val)
click to toggle source
Calls superclass method
# File lib/origen/mode.rb, line 57 def ==(val) if val.is_a?(Symbol) @current_mode == val else super end end
debug?()
click to toggle source
Any mode which is not production will return true here, if you want to test for only debug mode use Origen.mode
== :debug
# File lib/origen/mode.rb, line 45 def debug? !production? end
find_mode(name)
click to toggle source
# File lib/origen/mode.rb, line 27 def find_mode(name) name = name.to_s.downcase.to_sym if MODES.include?(name) name else mode = MODES.find do |m| m.to_s =~ /^#{name}/ end if mode mode else fail "Invalid mode requested, must be one of: #{MODES}" end end end
freeze()
click to toggle source
When called any future changes to the mode will be ignored
# File lib/origen/mode.rb, line 11 def freeze @frozen = true end
production?()
click to toggle source
# File lib/origen/mode.rb, line 49 def production? @current_mode == :production end
set(val)
click to toggle source
# File lib/origen/mode.rb, line 19 def set(val) @current_mode = find_mode(val) unless @frozen end
simulation?()
click to toggle source
# File lib/origen/mode.rb, line 53 def simulation? @current_mode == :simulation end
to_s()
click to toggle source
# File lib/origen/mode.rb, line 23 def to_s @current_mode ? @current_mode.to_s : '' end
unfreeze()
click to toggle source
# File lib/origen/mode.rb, line 15 def unfreeze @frozen = false end