Class: Logaling::Command::Renderers::TermJsonRenderer
- Inherits:
-
TermRenderer
- Object
- TermRenderer
- Logaling::Command::Renderers::TermJsonRenderer
- Defined in:
- lib/logaling/command/renderers.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#last_index ⇒ Object
Returns the value of attribute last_index.
Instance Method Summary collapse
-
#initialize(term, repository, config, options) ⇒ TermJsonRenderer
constructor
A new instance of TermJsonRenderer.
- #render(output) ⇒ Object
Methods inherited from TermRenderer
#glossary_name, #note, #source_term, #target_term
Constructor Details
#initialize(term, repository, config, options) ⇒ TermJsonRenderer
Returns a new instance of TermJsonRenderer.
138 139 140 141 142 |
# File 'lib/logaling/command/renderers.rb', line 138 def initialize(term, repository, config, ) super @index = 0 @last_index = 0 end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
136 137 138 |
# File 'lib/logaling/command/renderers.rb', line 136 def index @index end |
#last_index ⇒ Object
Returns the value of attribute last_index.
136 137 138 |
# File 'lib/logaling/command/renderers.rb', line 136 def last_index @last_index end |
Instance Method Details
#render(output) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/logaling/command/renderers.rb', line 144 def render(output) first_line? ? output.puts("[") : output.puts(",") record = { :source => source_term, :target => target_term, :note => note, :source_language => @config.source_language, :target_language => @config.target_language, :glossary => glossary_name } output.print JSON.pretty_generate(record) output.puts("\n]") if last_line? end |