Class: IsbmAdaptor::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/isbm_adaptor/channel.rb

Constant Summary collapse

TYPES =

Channel types permitted by the ISBM specification

['Publication', 'Request']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, type, description) ⇒ Channel

Creates a new Channel.

Parameters:

  • uri (String)

    the channel URI

  • type (String)

    the channel type, either ‘Publication’ or ‘Request’

  • description (String)

    the channel description



20
21
22
23
24
# File 'lib/isbm_adaptor/channel.rb', line 20

def initialize(uri, type, description)
  @uri = uri.to_s
  @type = type
  @description = description.to_s unless description.nil?
end

Instance Attribute Details

#descriptionString

Returns the channel description.

Returns:

  • (String)

    the channel description



13
14
15
# File 'lib/isbm_adaptor/channel.rb', line 13

def description
  @description
end

#typeString

Returns the channel type, either ‘Publication’ or ‘Request’.

Returns:

  • (String)

    the channel type, either ‘Publication’ or ‘Request’



10
11
12
# File 'lib/isbm_adaptor/channel.rb', line 10

def type
  @type
end

#uriString

Returns the channel URI.

Returns:

  • (String)

    the channel URI



7
8
9
# File 'lib/isbm_adaptor/channel.rb', line 7

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates a new Channel based on a hash.

Parameters:

  • hash (Hash)

    a customizable set of options

Options Hash (hash):

  • :channel_uri (String)

    the channel URI

  • :channel_type (String)

    the channel type, either ‘Publication’ or ‘Request’

  • :channel_description (String)

    the channel description



31
32
33
34
35
36
# File 'lib/isbm_adaptor/channel.rb', line 31

def self.from_hash(hash)
  uri = hash[:channel_uri]
  type = hash[:channel_type]
  description = hash[:channel_description]
  new(uri, type, description)
end