Sha256: 5fa2451edd9f1df17c87778a93dce836124c50d582e3736937e983bcd9087f20

Contents?: true

Size: 1007 Bytes

Versions: 7

Compression:

Stored size: 1007 Bytes

Contents

module RelatonIsoBib
  class TypedTitleString < RelatonBib::TypedTitleString
    # TITLE_TYPES = %w[title-main title-intro title-part main].freeze

    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength

    # @param type [String]
    # @param title [RelatonBib::FormattedString, Hash]
    # @param content [String]
    # @param language [String]
    # @param script [String]
    def initialize(**args)
      # if args[:type] && !TITLE_TYPES.include?(args[:type])
      #   raise ArgumentError, %{The type #{args[:type]} is invalid.}
      # end

      unless args[:title] || args[:content]
        raise ArgumentError, %{Keyword "title" or "content" should be passed.}
      end

      @type = args[:type]

      if args[:title]
        @title = args[:title]
      else
        fsargs = args.select { |k, _v| %i[content language script format].include? k }
        @title = RelatonBib::FormattedString.new(fsargs)
      end
    end
    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
relaton-iso-bib-1.1.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-1.1.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-1.0.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-1.0.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.9.2 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.9.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.9.0 lib/relaton_iso_bib/typed_title_string.rb