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.8.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.8.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.7.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.6.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.5.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.4.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.4.0 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.12 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.11 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.10 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.9 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.8 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.7 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.6 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.5 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.4 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.3 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.2 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.1 lib/relaton_iso_bib/typed_title_string.rb
relaton-iso-bib-0.3.0 lib/relaton_iso_bib/typed_title_string.rb