Sha256: 5130cd365ebdc83c023e487a939e163cd021b563d5253f36743f29af8cc4beb7

Contents?: true

Size: 515 Bytes

Versions: 7

Compression:

Stored size: 515 Bytes

Contents

module Poms
  module HasBaseAttributes
    def title
      return @title if @title
      main_title = select_title_by_type 'MAIN'
      sub_title = select_title_by_type 'SUB'
      @titel = (sub_title && sub_title.match(main_title)) ? sub_title : [main_title, sub_title].compact.join(": ")
    end

    def description
      @description ||= descriptions.first.value rescue nil
    end

    private

    def select_title_by_type(type)
      titles.select { |t| t.type == type }.map(&:value).first
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
poms-0.0.10 lib/poms/has_base_attributes.rb
poms-0.0.9 lib/poms/has_base_attributes.rb
poms-0.0.8 lib/poms/has_base_attributes.rb
poms-0.0.6 lib/poms/has_base_attributes.rb
poms-0.0.5 lib/poms/has_base_attributes.rb
poms-0.0.4 lib/poms/has_base_attributes.rb
poms-0.0.3 lib/poms/has_base_attributes.rb