Class: Logwriter::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/logwriter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_string) ⇒ Logger

Returns a new instance of Logger.



7
8
9
10
11
12
# File 'lib/logwriter.rb', line 7

def initialize(path_string)
  @target_filepath = path_string
  File.open(target_filepath, 'a') do |io|
    io.print "\n#{Time.now.inspect}\n" 
  end
end

Instance Attribute Details

#target_filepathObject (readonly)

Returns the value of attribute target_filepath.



5
6
7
# File 'lib/logwriter.rb', line 5

def target_filepath
  @target_filepath
end

Instance Method Details

#c(target_object) ⇒ Object



21
22
23
24
25
# File 'lib/logwriter.rb', line 21

def c(target_object)
  File.open(@target_filepath, 'a') do |io|
    io.puts "object: #{target_object}, class: #{target_object.class}, superclass: #{target_object.class.superclass}"
  end
end

#f(flg_number) ⇒ Object



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

def f(flg_number)
  File.open(@target_filepath, 'a') do |io|
    io.puts "/~~  #{flg_number} flaged  "
  end
end

#v(target_object, valiable_name = 'value') ⇒ Object



14
15
16
17
18
19
# File 'lib/logwriter.rb', line 14

def v(target_object, valiable_name = 'value')
  File.open(@target_filepath, 'a') do |io|
    io.print "#{valiable_name}: "
    io.print "#{target_object.inspect}\n"
  end
end