Class: Instadoc::Java::JavaFile

Inherits:
Object
  • Object
show all
Defined in:
lib/instadoc/java/java_file.rb

Constant Summary collapse

DOC_REGEX =
'@InstaDoc\(\"(.*)\"\)'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, pathname) ⇒ JavaFile

Returns a new instance of JavaFile.



18
19
20
21
22
23
# File 'lib/instadoc/java/java_file.rb', line 18

def initialize(config, pathname)
  @config = config
  @pathname = pathname
  @documented_lines = Hash.new()
  valid?
end

Instance Attribute Details

#documented_linesObject

Returns the value of attribute documented_lines.



26
27
28
# File 'lib/instadoc/java/java_file.rb', line 26

def documented_lines
  @documented_lines
end

#pathnameObject

Returns the value of attribute pathname.



25
26
27
# File 'lib/instadoc/java/java_file.rb', line 25

def pathname
  @pathname
end

Class Method Details

.create_files(config, path_names) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/instadoc/java/java_file.rb', line 8

def self.create_files(config, path_names)
  files = Array.new
  path_names.each { |pathname|
    java_file = JavaFile.new(config, pathname)
    java_file.search_documentation
    files << java_file
  }
  return files
end

Instance Method Details

#nameObject



55
56
57
# File 'lib/instadoc/java/java_file.rb', line 55

def name()
  @pathname.basename.to_s
end

#name_with_packageObject



59
60
61
# File 'lib/instadoc/java/java_file.rb', line 59

def name_with_package()
  @pathname.relative_path_from(@config.input_path).to_s
end

#search_documentationObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/instadoc/java/java_file.rb', line 41

def search_documentation()
  line_number = 0

  @pathname.each_line { |line|
    line_number = line_number.succ
    match = line.match(DOC_REGEX)
    if (match)
      @documented_lines[line_number] = match[1]
    end
  }

  return @documented_lines
end

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'lib/instadoc/java/java_file.rb', line 28

def valid?
  unless @config
    raise ArgumentError, "#{self} requires a configuration"
  end
  unless @pathname.file?
    raise ArgumentError, "#{self} requires a file Given was => #{@pathname}"
  end
end