Module: Tick

Defined in:
lib/tick.rb,
lib/tick/version.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.color=(is_turn_on) ⇒ Object



28
29
30
31
# File 'lib/tick.rb', line 28

def self.color=(is_turn_on)
  return unless is_turn_on.kind_of?(TrueClass) || is_turn_on.kind_of?(FalseClass)
  Sickill::Rainbow.enabled = is_turn_on
end

.desc_colorObject



52
53
54
# File 'lib/tick.rb', line 52

def self.desc_color 
  @desc_color
end

.desc_color=(color) ⇒ Object



56
57
58
# File 'lib/tick.rb', line 56

def self.desc_color=(color) 
  @desc_color = color
end

.desc_messageObject



42
43
44
# File 'lib/tick.rb', line 42

def self.desc_message
  @desc_message ||= lambda {|class_name, method_name| "TICK: method '#{method_name}' in class '#{class_name}'"}
end

.desc_message=(block) ⇒ Object

Raises:

  • (ArgumentError)


46
47
48
49
50
# File 'lib/tick.rb', line 46

def self.desc_message=(block)
  return @desc_message = nil if block.nil?
  raise ArgumentError.new("wrong number of arguments (#{block.arity} for 2)") if block.arity != 2
  @desc_message = block
end

.enabledObject



33
34
35
36
# File 'lib/tick.rb', line 33

def self.enabled 
  @enabled = true if @enabled.nil?
  @enabled
end

.enabled=(is_turn_on) ⇒ Object



38
39
40
# File 'lib/tick.rb', line 38

def self.enabled=(is_turn_on) 
  @enabled = is_turn_on
end

.included(base) ⇒ Object



9
10
11
12
# File 'lib/tick.rb', line 9

def self.included(base)
  base.extend(ClassMethods)    
  base.send(:include, InstanceMethods)    
end

.loggerObject



14
15
16
17
18
19
20
21
22
# File 'lib/tick.rb', line 14

def self.logger
  return @logger if @logger

  if defined?(Rails)
    Rails.logger
  else 
    Logger.new(STDOUT)
  end
end

.logger=(logger) ⇒ Object



24
25
26
# File 'lib/tick.rb', line 24

def self.logger=(logger) 
  @logger = logger
end

.resetObject



78
79
80
81
82
83
84
85
# File 'lib/tick.rb', line 78

def self.reset 
  self.enabled = true 
  self.color = true 
  @desc_message = nil 
  @time_message = nil 
  @desc_color = nil 
  @time_color = nil
end

.time_colorObject



70
71
72
# File 'lib/tick.rb', line 70

def self.time_color
  @time_color
end

.time_color=(color) ⇒ Object



74
75
76
# File 'lib/tick.rb', line 74

def self.time_color=(color) 
  @time_color = color
end

.time_messageObject



60
61
62
# File 'lib/tick.rb', line 60

def self.time_message
  @time_message ||= lambda { |sec| "(#{sec.to_s} s)" }
end

.time_message=(block) ⇒ Object

Raises:

  • (ArgumentError)


64
65
66
67
68
# File 'lib/tick.rb', line 64

def self.time_message=(block)
  return @time_message = nil if block.nil?
  raise ArgumentError.new("wrong number of arguments (#{block.arity} for 1)") if block.arity != 1
  @time_message = block
end