Class: Pubid::Export::IdentifierTypeResult

Inherits:
Object
  • Object
show all
Defined in:
lib/pubid/export/result.rb

Overview

Immutable value object representing extracted metadata for one identifier type. Encapsulates all data needed by the website for a single doc type entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, title:, short: nil, abbr: [], typed_stages: [], examples: []) ⇒ IdentifierTypeResult

Returns a new instance of IdentifierTypeResult.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pubid/export/result.rb', line 10

def initialize(key:, title:, short: nil, abbr: [], typed_stages: [],
examples: [])
  @key = key.to_s
  @title = title
  @short = short
  @abbr = Array(abbr).map(&:to_s)
  @typed_stages = typed_stages.map do |ts|
    TypedStageResult.from_typed_stage(ts)
  end
  @examples = examples
  freeze
end

Instance Attribute Details

#abbrObject (readonly)

Returns the value of attribute abbr.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def abbr
  @abbr
end

#examplesObject (readonly)

Returns the value of attribute examples.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def examples
  @examples
end

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def key
  @key
end

#shortObject (readonly)

Returns the value of attribute short.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def short
  @short
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def title
  @title
end

#typed_stagesObject (readonly)

Returns the value of attribute typed_stages.



8
9
10
# File 'lib/pubid/export/result.rb', line 8

def typed_stages
  @typed_stages
end

Instance Method Details

#to_hObject Also known as: to_hash



23
24
25
26
27
28
29
30
31
32
# File 'lib/pubid/export/result.rb', line 23

def to_h
  {
    key: @key,
    title: @title,
    short: @short,
    abbr: @abbr,
    typed_stages: @typed_stages.map(&:to_h),
    examples: @examples,
  }
end