Sha256: d650db6218470a5efdd180dccfb48fa8ff006e7fdc5244b0f5b48cb4ca51ad4a

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

module Calrom
  module Formatter
    # Prints list of available bundled calendars
    class Calendars < Formatter
      def call(calendar, date_range)
        last_locale = nil
        CR::Data.each do |d|
          sanctorale = d.load_with_parents
          meta = sanctorale.metadata
          puts if last_locale && last_locale != meta['locale']
          default = d == Config::DEFAULT_DATA ? ' [default]' : ''
          puts "%-20s:  %s  [%s]%s" % [d.siglum, meta['title'], meta['locale'], default]

          next unless meta['components']

          parents =
            meta['components']
              .collect {|c| c['extends'] }
              .compact
              .map {|e| e.is_a?(Array) ? e : [e] } # 'extends' is String or Array
              .flatten
              .map {|p| p.sub(/\.\w{3,4}$/, '') } # file name to "siglum"
          parents.each {|p| puts "  <  #{p}" }
          last_locale = meta['locale']
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calrom-0.4.0 lib/calrom/formatter/calendars.rb