Sha256: 199fe0a4d16ea76ebbc051325eee982d2deb0cd7088a09d14a436e1b0f7847e9

Contents?: true

Size: 671 Bytes

Versions: 10

Compression:

Stored size: 671 Bytes

Contents

require 'typesafe_enum'

module BerkeleyLibrary
  module TIND
    module API
      class Format < TypesafeEnum::Base
        %i[ID XML FILES JSON].each { |fmt| new(fmt) }

        def to_s
          # noinspection RubyYardReturnMatch
          value
        end

        def to_str
          value
        end

        class << self
          def ensure_format(format)
            return unless format
            return format if format.is_a?(Format)

            fmt = Format.find_by_value(format.to_s.downcase)
            return fmt if fmt

            raise ArgumentError, "Unknown #{Format}: #{format.inspect}"
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.7.1 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.7.0 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.6.0 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.5.1 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.5.0 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.4.3 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.4.2 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.4.1 lib/berkeley_library/tind/api/format.rb
berkeley_library-tind-0.4.0 lib/berkeley_library/tind/api/format.rb