Class: Calrom::Config
- Inherits:
-
Object
- Object
- Calrom::Config
- Defined in:
- lib/calrom/config.rb
Constant Summary collapse
- DEFAULT_DATA =
CR::Data::GENERAL_ROMAN_ENGLISH
- DEFAULT_LOCALE =
:en
Instance Attribute Summary collapse
-
#colours ⇒ Object
Returns the value of attribute colours.
-
#configs ⇒ Object
Returns the value of attribute configs.
-
#date_range ⇒ Object
Returns the value of attribute date_range.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#sanctorale ⇒ Object
Returns the value of attribute sanctorale.
-
#today ⇒ Object
Returns the value of attribute today.
Instance Method Summary collapse
- #build_sanctorale ⇒ Object
- #calendar ⇒ Object
- #highlighter(colourful) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
Instance Attribute Details
#colours ⇒ Object
Returns the value of attribute colours.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def colours @colours end |
#configs ⇒ Object
Returns the value of attribute configs.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def configs @configs end |
#date_range ⇒ Object
Returns the value of attribute date_range.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def date_range @date_range end |
#formatter ⇒ Object
Returns the value of attribute formatter.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def formatter @formatter end |
#locale ⇒ Object
Returns the value of attribute locale.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def locale @locale end |
#sanctorale ⇒ Object
Returns the value of attribute sanctorale.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def sanctorale @sanctorale end |
#today ⇒ Object
Returns the value of attribute today.
13 14 15 |
# File 'lib/calrom/config.rb', line 13 def today @today end |
Instance Method Details
#build_sanctorale ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
15 16 17 |
# File 'lib/calrom/config.rb', line 15 def calendar CR::PerpetualCalendar.new(sanctorale: build_sanctorale) end |
#highlighter(colourful) ⇒ Object
61 62 63 64 65 66 67 |
# 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 |