Class: Factbook::Almanac
- Inherits:
-
Object
- Object
- Factbook::Almanac
- Defined in:
- lib/factbook/almanac.rb
Defined Under Namespace
Classes: PageCtx
Class Method Summary collapse
-
.from_json(codes, json_dir: '.') ⇒ Object
convenience helper (“factory”).
Instance Method Summary collapse
-
#initialize(pages) ⇒ Almanac
constructor
A new instance of Almanac.
- #render(template) ⇒ Object
Constructor Details
#initialize(pages) ⇒ Almanac
Returns a new instance of Almanac.
15 16 17 |
# File 'lib/factbook/almanac.rb', line 15 def initialize( pages ) @pages = pages end |
Class Method Details
.from_json(codes, json_dir: '.') ⇒ Object
convenience helper (“factory”)
9 10 11 12 |
# File 'lib/factbook/almanac.rb', line 9 def self.from_json( codes, json_dir: '.' ) pages = JsonPageReader.new( json_dir ).read_pages( codes ) self.new( pages ) end |
Instance Method Details
#render(template) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/factbook/almanac.rb', line 19 def render( template ) buf = '' @pages.each do |page| text = PageCtx.new( page, template ).render puts text ## for debugging write country profile to console (too) buf << text end puts "count: #{@pages.count}" buf ## return buffered almanac text end |