Class: ContributorsStats::Formatter
- Inherits:
-
Object
- Object
- ContributorsStats::Formatter
- Defined in:
- lib/contributors_stats/formatter.rb,
lib/plugins/contributors_stats/formatter/html.rb
Overview
Takes care of formatting data and saving it
Defined Under Namespace
Classes: Html
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(data, type = :html, options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
-
#save(*targets) ⇒ Object
overwrite target with the formatted content.
-
#update(*targets, options: {}) ⇒ Object
update target with the formatted content.
Constructor Details
#initialize(data, type = :html, options = {}) ⇒ Formatter
Returns a new instance of Formatter.
11 12 13 |
# File 'lib/contributors_stats/formatter.rb', line 11 def initialize(data, type = :html, = {}) format(data, type, ) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/contributors_stats/formatter.rb', line 9 def content @content end |
Instance Method Details
#save(*targets) ⇒ Object
overwrite target with the formatted content
17 18 19 20 21 |
# File 'lib/contributors_stats/formatter.rb', line 17 def save(*targets) targets.flatten.each do |file| File.open(file, 'w') { |f| f.write(content * "\n") } end end |
#update(*targets, options: {}) ⇒ Object
update target with the formatted content
26 27 28 29 30 31 32 33 |
# File 'lib/contributors_stats/formatter.rb', line 26 def update(*targets, options: {}) targets.flatten.each do |file| plugin = plugins.first_ask!("updater", :handles?, file) update_file(file) do |file_content| plugin.update(file_content, content, ) end end end |