class Documentize::Documentize

Constants

REGEX

Attributes

collector[R]
file[R]
header[R]
informator[R]
tree[R]

Public Class Methods

new(file_name) click to toggle source
# File lib/documentize.rb, line 16
def initialize(file_name)
  @file = load_file(file_name)
  @collector = Collector.new
  @informator = Informator.new
end

Public Instance Methods

load_file(file_name) click to toggle source
# File lib/documentize.rb, line 22
def load_file(file_name)
  file = File.readlines(file_name).map {|line| line.strip} - [""]
  raise ArgumentError unless valid?(file_name, file[0])
  file
end
run() click to toggle source
# File lib/documentize.rb, line 28
def run
  @tree, @header = collector.run(@file)
  informator.gen_info(tree)
  informator.clear_screen

  Printer.print_with_docs(tree, header)
end

Private Instance Methods

valid?(file_name, shebang) click to toggle source
# File lib/documentize.rb, line 38
def valid?(file_name, shebang)
  if file_name =~ REGEX[:ext] || shebang =~ REGEX[:shbang]
    true
  else
    false
  end
end