Module: Pubid::Iso::Identifier

Extended by:
Core::Identifier
Defined in:
lib/pubid/iso/identifier.rb,
lib/pubid/iso/identifier/base.rb,
lib/pubid/iso/identifier/data.rb,
lib/pubid/iso/identifier/guide.rb,
lib/pubid/iso/identifier/extract.rb,
lib/pubid/iso/identifier/addendum.rb,
lib/pubid/iso/identifier/amendment.rb,
lib/pubid/iso/identifier/directives.rb,
lib/pubid/iso/identifier/supplement.rb,
lib/pubid/iso/identifier/corrigendum.rb,
lib/pubid/iso/identifier/recommendation.rb,
lib/pubid/iso/identifier/technical_report.rb,
lib/pubid/iso/identifier/technical_committee.rb,
lib/pubid/iso/identifier/international_standard.rb,
lib/pubid/iso/identifier/technical_specification.rb,
lib/pubid/iso/identifier/technology_trends_assessments.rb,
lib/pubid/iso/identifier/international_workshop_agreement.rb,
lib/pubid/iso/identifier/publicly_available_specification.rb,
lib/pubid/iso/identifier/international_standardized_profile.rb

Defined Under Namespace

Classes: Addendum, Amendment, Base, Corrigendum, Data, Directives, Extract, Guide, InternationalStandard, InternationalStandardizedProfile, InternationalWorkshopAgreement, PubliclyAvailableSpecification, Recommendation, Supplement, TechnicalCommittee, TechnicalReport, TechnicalSpecification, TechnologyTrendsAssessments

Class Method Summary collapse

Class Method Details

.parse(*args) ⇒ Object



6
7
8
# File 'lib/pubid/iso/identifier.rb', line 6

def parse(*args)
  Base.parse(*args)
end

.parse_from_title(title) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
# File 'lib/pubid/iso/identifier.rb', line 10

def parse_from_title(title)
  title.split.reverse.inject(title) do |acc, part|
    return Base.parse(acc)
  rescue Pubid::Core::Errors::ParseError
    # delete parts from the title until it's parseable
    acc.reverse.sub(part.reverse, "").reverse.strip
  end

  raise Errors::ParseError, "cannot parse #{title}"
end