Class: GalleryGenerator::GalleryConfig
- Inherits:
-
Object
- Object
- GalleryGenerator::GalleryConfig
- Defined in:
- lib/m1key_gallery_generator/gallery_config.rb
Instance Attribute Summary collapse
-
#blurb ⇒ Object
readonly
Returns the value of attribute blurb.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#map_title ⇒ Object
readonly
Returns the value of attribute map_title.
-
#map_url ⇒ Object
readonly
Returns the value of attribute map_url.
-
#photos ⇒ Object
readonly
Returns the value of attribute photos.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#small_print ⇒ Object
readonly
Returns the value of attribute small_print.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#upload_date ⇒ Object
readonly
Returns the value of attribute upload_date.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(yaml_config_file_name) ⇒ GalleryConfig
constructor
A new instance of GalleryConfig.
- #photo_id_digits ⇒ Object
- #total_photos_number ⇒ Object
Constructor Details
#initialize(yaml_config_file_name) ⇒ GalleryConfig
Returns a new instance of GalleryConfig.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 10 def initialize(yaml_config_file_name) puts "Attempting to parse #{yaml_config_file_name} to read gallery configuration..." gallery_configuration = YAML.safe_load_file(yaml_config_file_name, permitted_classes: [Date, Symbol], permitted_symbols: []) puts 'Parsed, seemingly.' puts @title = gallery_configuration['title'] puts "Gallery title is [#{@title}]." @map_url = gallery_configuration['map']['url'] puts "Map url is [#{@map_url}]." @map_title = gallery_configuration['map']['title'] puts "Map title is [#{@map_title}]." @slug = gallery_configuration['slug'] puts "Gallery slug is [#{@slug}]." @upload_date = gallery_configuration['upload_date'] puts "Gallery upload date is [#{@upload_date}]." @description = gallery_configuration['description'] puts "Gallery description is [#{compact(@description)}]." @small_print = gallery_configuration['small_print'] puts "Small print is [#{@small_print}]." @blurb = gallery_configuration['blurb'] puts "Gallery description is [#{compact(@blurb)}]." @sources = gallery_configuration['sources'] gallery_year_from_yaml = gallery_configuration['year'] if gallery_year_from_yaml == 'current' puts 'Using current year for gallery year...' current_year = Date.today.strftime('%Y') @year = Integer(current_year) else @year = Integer(gallery_year_from_yaml) unless @year > 999 and @year < 10000 abort 'Gallery year should be exactly four digits long.' end end puts "Gallery year is [#{year}]." puts @photos = gallery_configuration['photos'] end |
Instance Attribute Details
#blurb ⇒ Object (readonly)
Returns the value of attribute blurb.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def blurb @blurb end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def description @description end |
#map_title ⇒ Object (readonly)
Returns the value of attribute map_title.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def map_title @map_title end |
#map_url ⇒ Object (readonly)
Returns the value of attribute map_url.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def map_url @map_url end |
#photos ⇒ Object (readonly)
Returns the value of attribute photos.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def photos @photos end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def slug @slug end |
#small_print ⇒ Object (readonly)
Returns the value of attribute small_print.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def small_print @small_print end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def sources @sources end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def title @title end |
#upload_date ⇒ Object (readonly)
Returns the value of attribute upload_date.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def upload_date @upload_date end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
8 9 10 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 8 def year @year end |
Instance Method Details
#photo_id_digits ⇒ Object
56 57 58 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 56 def photo_id_digits [2, total_photos_number.to_s.size].max end |
#total_photos_number ⇒ Object
52 53 54 |
# File 'lib/m1key_gallery_generator/gallery_config.rb', line 52 def total_photos_number @photos.size end |