Class: Source

Inherits:
Struct show all
Defined in:
lib/models/source.rb

Overview

Class Source represents structure of source

source = Source.new
source.name        # => String
source.code        # => String
source.logo_url    # => String
source.logo_sm_url # => String
source.hidden      # => Boolean

source.from_array(array) # =>  Array of Source objects

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

from_hash

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



12
13
14
# File 'lib/models/source.rb', line 12

def code
  @code
end

#hiddenObject

Returns the value of attribute hidden

Returns:

  • (Object)

    the current value of hidden



12
13
14
# File 'lib/models/source.rb', line 12

def hidden
  @hidden
end

#logo_sm_urlObject

Returns the value of attribute logo_sm_url

Returns:

  • (Object)

    the current value of logo_sm_url



12
13
14
# File 'lib/models/source.rb', line 12

def logo_sm_url
  @logo_sm_url
end

#logo_urlObject

Returns the value of attribute logo_url

Returns:

  • (Object)

    the current value of logo_url



12
13
14
# File 'lib/models/source.rb', line 12

def logo_url
  @logo_url
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



12
13
14
# File 'lib/models/source.rb', line 12

def name
  @name
end

Class Method Details

.from_array(array) ⇒ Object

Method from_array returns array of sources(create from json). Takes value of array objects as json parameter array.

Example:

Source.from_array([...array of JSON objects...]) # => Array of Source


22
23
24
25
26
# File 'lib/models/source.rb', line 22

def self.from_array(array)
  array.collect do |element|
    Source.new(element)
  end
end