Sha256: dbc48929a038b74c0e28f2c7b62ce36f6070a372cd01dd8ba6e3d2805d5cfbdf

Contents?: true

Size: 999 Bytes

Versions: 26

Compression:

Stored size: 999 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

26 entries across 26 versions & 1 rubygems

Version Path
relaton-iso-bib-0.2.4 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.2.3 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.2.2 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.2.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.2.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.1.0 lib/relaton_iso_bib/typed_title_string.rb