Module: SugarCube::Legacy

Defined in:
lib/sugarcube-legacy/log.rb

Class Method Summary collapse

Class Method Details

.flush_log(notification = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sugarcube-legacy/log.rb', line 21

def flush_log(notification=nil)
  return unless @log && ! @log.empty?

  output = "SugarCube recorded the following warnings:"
  @log.uniq.each do |message|
    output << "\n"
    output << message
  end
  NSLog(output)
  @log = nil
end

.log(message = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sugarcube-legacy/log.rb', line 5

def log(message=nil)
  @log ||= []

  if message.nil?
    return @log
  end

  if log?
    log << message
  else
    NSLog(message)
  end

  self
end

.log?(value = nil) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
# File 'lib/sugarcube-legacy/log.rb', line 33

def log?(value=nil)
  if value.nil?
    @logging
  else
    @logging = value
    unless @logging
      @log = nil
    end
  end
end