Class: Pubid::Export::FlavorResult

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

Overview

Immutable value object for extracted flavor metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flavor:, identifier_types:, wrapper_types: [], attributes: []) ⇒ FlavorResult

Returns a new instance of FlavorResult.



74
75
76
77
78
79
80
81
# File 'lib/pubid/export/result.rb', line 74

def initialize(flavor:, identifier_types:, wrapper_types: [],
attributes: [])
  @flavor = flavor.to_s
  @identifier_types = identifier_types
  @wrapper_types = wrapper_types
  @attributes = attributes
  freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



72
73
74
# File 'lib/pubid/export/result.rb', line 72

def attributes
  @attributes
end

#flavorObject (readonly)

Returns the value of attribute flavor.



72
73
74
# File 'lib/pubid/export/result.rb', line 72

def flavor
  @flavor
end

#identifier_typesObject (readonly)

Returns the value of attribute identifier_types.



72
73
74
# File 'lib/pubid/export/result.rb', line 72

def identifier_types
  @identifier_types
end

#wrapper_typesObject (readonly)

Returns the value of attribute wrapper_types.



72
73
74
# File 'lib/pubid/export/result.rb', line 72

def wrapper_types
  @wrapper_types
end

Instance Method Details

#to_hObject Also known as: to_hash



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/pubid/export/result.rb', line 83

def to_h
  h = {
    identifier_types: @identifier_types.map(&:to_h),
    attributes: @attributes,
  }
  unless @wrapper_types.empty?
    h[:wrapper_types] =
      @wrapper_types.map(&:to_h)
  end
  h
end