class TokyoMetro::Factory::Seed::Common::Group

Public Class Methods

new( *args , class_name , method_name , indent , no_display , not_on_the_top_layer , display_number , other_info , interrupt ) click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 6
def initialize( *args , class_name , method_name , indent , no_display , not_on_the_top_layer , display_number , other_info , interrupt )
  if no_display and display_number
    raise "Error: Do you want to display number? You set both of \'no_display\' and \'display_number\'."
  end
  @class_name = class_name
  @method_name = method_name
  @indent = indent
  @no_display = no_display
  @not_on_the_top_layer = not_on_the_top_layer
  @display_number = display_number
  @other_info = other_info

  @interrupt = interrupt

  set_optional_variables( args )
end
process( *variables ) click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 23
def self.process( *variables )
  self.new( *variables ).seed
end

Private Instance Methods

display_number( item , now_at ) click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 64
def display_number( item , now_at )
  if @display_number
    str = ::String.new
    now_at_to_s = now_at.to_s.rjust( whole.to_s.length )
    str << " " * ( @indent + 1 ) * 4 + " \[#{ now_at_to_s }/#{ whole }\]"
    if item.methods.include?( :same_as )
      str << " " + item.same_as
    elsif item.methods.include?( :id_urn )
      str << " " + item.id_urn
    end
    puts str
  end
end
inspect_time() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 78
def inspect_time
  unless @no_display
    @time_end = ::Time.now
    t = calc_time( @time_begin , @time_end )
    puts ""
    puts " " * @indent * 4 + "*" + "#{ t.to_s.rjust(8) } sec / End: #{ @time_end.to_s }"
    puts ""
  end
end
inspect_title() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 38
def inspect_title
  unless @no_display
    if @not_on_the_top_layer
      puts ""
    end
    puts title_for_inspection
    puts ""
  end
end
inspection() { || ... } click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 29
def inspection
  inspect_title
  @time_begin = ::Time.now

  yield

  inspect_time
end
interruption() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 100
def interruption
  if @interrupt
    ::TokyoMetro::Factory::Seed::Common::Interruption.start!
  end
end
seed_optional_infos() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 96
def seed_optional_infos
  nil
end
set_optional_variables( args ) click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 92
def set_optional_variables( args )
  nil
end
title_for_inspection() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 48
def title_for_inspection
  str = ::String.new
  str << " " * @indent * 4
  unless @not_on_the_top_layer
    str << "●"
  else
    str << "○"
  end
  str << " #{ @class_name }\##{ @method_name }"
  if @other_info.present?
    str << " #{ @other_info }"
  end

  str
end
whole() click to toggle source
# File lib/tokyo_metro/factory/seed/common/group.rb, line 88
def whole
  @array_to_seed.length
end