Class: TVTid::Category

Inherits:
Object
  • Object
show all
Defined in:
library/tvtid/category.rb

Overview

A category for an EPG entry.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Category

Constructs a new category with a name.



10
11
12
# File 'library/tvtid/category.rb', line 10

def initialize name
  @name = name
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'library/tvtid/category.rb', line 6

def color
  @color
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'library/tvtid/category.rb', line 7

def name
  @name
end

#shadeObject

Returns the value of attribute shade.



6
7
8
# File 'library/tvtid/category.rb', line 6

def shade
  @shade
end

Class Method Details

.from_json(json) ⇒ Object

Creates a new category from a json object.



17
18
19
20
21
22
23
24
# File 'library/tvtid/category.rb', line 17

def self.from_json json
  return nil unless json['name']

  Category.new(json['name']).tap do |category|
    category.color = json['color']
    category.shade = json['shade']
  end
end