Class: LOCat::Template
- Inherits:
-
Object
- Object
- LOCat::Template
- Defined in:
- lib/locat/template.rb
Constant Summary collapse
- DIRECTORY =
File.dirname(__FILE__) + '/template'
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #counts ⇒ Object
-
#initialize(counter, metadata) ⇒ Template
constructor
A new instance of Template.
- #javascript ⇒ Object
- #render(template) ⇒ Object
- #scm? ⇒ Boolean
- #table_loc ⇒ Object
- #table_pcnt ⇒ Object (also: #table_percentages)
- #table_ratio ⇒ Object
- #table_scm ⇒ Object
- #title ⇒ Object
- #to_json ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(counter, metadata) ⇒ Template
Returns a new instance of Template.
10 11 12 13 |
# File 'lib/locat/template.rb', line 10 def initialize(counter, ) @counter = counter @metadata = end |
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
16 17 18 |
# File 'lib/locat/template.rb', line 16 def counter @counter end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
19 20 21 |
# File 'lib/locat/template.rb', line 19 def @metadata end |
Instance Method Details
#counts ⇒ Object
27 28 29 |
# File 'lib/locat/template.rb', line 27 def counts counter.counts end |
#javascript ⇒ Object
75 76 77 78 79 |
# File 'lib/locat/template.rb', line 75 def javascript @javascript ||= ( File.read(File.join(DIRECTORY, 'javascript.js')) ) end |
#render(template) ⇒ Object
82 83 84 85 86 |
# File 'lib/locat/template.rb', line 82 def render(template) file = File.join(DIRECTORY, template + '.rhtml') erb = ERB.new(File.read(file)) erb.result(__binding__) end |
#scm? ⇒ Boolean
65 66 67 |
# File 'lib/locat/template.rb', line 65 def scm? File.directory?('.git') end |
#table_loc ⇒ Object
32 33 34 |
# File 'lib/locat/template.rb', line 32 def table_loc counter.loc end |
#table_pcnt ⇒ Object Also known as: table_percentages
37 38 39 |
# File 'lib/locat/template.rb', line 37 def table_pcnt counter.percent end |
#table_ratio ⇒ Object
45 46 47 |
# File 'lib/locat/template.rb', line 45 def table_ratio counter.ratio end |
#table_scm ⇒ Object
50 51 52 |
# File 'lib/locat/template.rb', line 50 def table_scm counter.scm end |
#title ⇒ Object
70 71 72 |
# File 'lib/locat/template.rb', line 70 def title "The LOCat on " + (['title'] || File.basename(Dir.pwd)) end |
#to_json ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/locat/template.rb', line 55 def to_json h = {} h[:loc] = table_loc h[:pcnt] = table_pcnt h[:ratio] = table_ratio h[:scm] = table_scm if scm? h.to_json end |
#total ⇒ Object
22 23 24 |
# File 'lib/locat/template.rb', line 22 def total counter.total end |