Class: ResourcesNav::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/resources_nav/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_name, options = {}) ⇒ Resource

Returns a new instance of Resource.



4
5
6
7
# File 'lib/resources_nav/resource.rb', line 4

def initialize(_name, options={})
  @name = _name
  @icon = options[:icon] if options.is_a?(Hash)
end

Instance Attribute Details

#iconObject

Returns the value of attribute icon.



3
4
5
# File 'lib/resources_nav/resource.rb', line 3

def icon
  @icon
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/resources_nav/resource.rb', line 3

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/resources_nav/resource.rb', line 9

def ==(other)
  if other.is_a?(Symbol)
    name == other
  elsif other.is_a?(String)
    to_s == other
  elsif other.is_a?(self.class)
    name == other.name
  else
    false
  end
end

#to_sObject



21
22
23
# File 'lib/resources_nav/resource.rb', line 21

def to_s
  to_sym.to_s
end

#to_symObject



25
26
27
# File 'lib/resources_nav/resource.rb', line 25

def to_sym
  name
end