Class: Docs::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/docs/core/models/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, path = nil, type = nil) ⇒ Entry

Returns a new instance of Entry


5
6
7
8
9
# File 'lib/docs/core/models/entry.rb', line 5

def initialize(name = nil, path = nil, type = nil)
  self.name = name
  self.path = path
  self.type = type
end

Instance Attribute Details

#nameObject

Returns the value of attribute name


3
4
5
# File 'lib/docs/core/models/entry.rb', line 3

def name
  @name
end

#pathObject

Returns the value of attribute path


3
4
5
# File 'lib/docs/core/models/entry.rb', line 3

def path
  @path
end

#typeObject

Returns the value of attribute type


3
4
5
# File 'lib/docs/core/models/entry.rb', line 3

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object


15
16
17
# File 'lib/docs/core/models/entry.rb', line 15

def <=>(other)
  name.to_s.casecmp(other.name.to_s)
end

#==(other) ⇒ Object


11
12
13
# File 'lib/docs/core/models/entry.rb', line 11

def ==(other)
  other.name == name && other.path == path && other.type == type
end

#as_jsonObject


31
32
33
# File 'lib/docs/core/models/entry.rb', line 31

def as_json
  { name: name, path: path, type: type }
end

#root?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/docs/core/models/entry.rb', line 27

def root?
  path == 'index'
end