class Calrom::Config
Constants
- DEFAULT_DATA
- DEFAULT_LOCALE
Attributes
colours[RW]
configs[RW]
date_range[RW]
formatter[RW]
locale[RW]
sanctorale[RW]
today[RW]
Public Class Methods
new()
click to toggle source
# File lib/calrom/config.rb, line 6 def initialize self.today = Date.today self.date_range = Month.new(today.year, today.month) self.sanctorale = [] self.configs = [] end
Public Instance Methods
build_sanctorale()
click to toggle source
# File lib/calrom/config.rb, line 19 def build_sanctorale if @sanctorale.empty? return DEFAULT_DATA.load end data = @sanctorale.collect do |s| if s == '-' CR::SanctoraleLoader.new.load_from_string STDIN.read elsif File.file? s CR::SanctoraleLoader.new.load_from_file s elsif CR::Data[s] CR::Data[s].load else raise InputError.new "\"#{s}\" is neither a file, nor a valid identifier of a bundled calendar. " + "Valid identifiers are: " + CR::Data.each.collect(&:siglum).inspect end end CR::SanctoraleFactory.create_layered(*data) end
calendar()
click to toggle source
# File lib/calrom/config.rb, line 15 def calendar CR::PerpetualCalendar.new(sanctorale: build_sanctorale) end
highlighter(colourful)
click to toggle source
# File lib/calrom/config.rb, line 61 def highlighter(colourful) if (self.colours == false || (self.colours.nil? && !STDOUT.isatty)) return Highlighter::No.new end colourful.new end
Private Instance Methods
locale_in_file_name()
click to toggle source
# File lib/calrom/config.rb, line 71 def locale_in_file_name locale = (sanctorale.last || DEFAULT_DATA.siglum).split('-').last&.to_sym I18n.available_locales.include?(locale) ? locale : nil end