Class: TokyoMetro::Document::MakeExamples::Static::EachFile

Inherits:
Object
  • Object
show all
Defined in:
lib/tokyo_metro/document/make_examples/static/each_file.rb

Defined Under Namespace

Classes: EachMethod

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ EachFile

Returns a new instance of EachFile.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/tokyo_metro/document/make_examples/static/each_file.rb', line 3

def initialize( filename )
  @filename = filename
  ary = open( @filename , "r:utf-8" ).read.split( /\n{3,}/ )

  indent_n , *infos_of_method = ary
  @indent = indent_n.gsub( /\Aindent \: / , "" ).to_i
  @infos_of_method = infos_of_method.map { | info_in_rows |
    variables = info_in_rows.split( /\n+/ )
    EachMethod.new( @indent , *variables )
  }
end

Instance Method Details

#processObject



15
16
17
18
19
# File 'lib/tokyo_metro/document/make_examples/static/each_file.rb', line 15

def process
  file = ::File.open( filename_of_result , "w:utf-8" )
  file.print( @infos_of_method.map( &:to_s ).join( "\n" * 3 ) )
  file.close
end