Class: Mutiny::Subjects::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/subjects/subject.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, path: nil, root: nil) ⇒ Subject



8
9
10
11
12
# File 'lib/mutiny/subjects/subject.rb', line 8

def initialize(name:, path: nil, root: nil)
  @name = name
  @path = path
  @root = root
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/mutiny/subjects/subject.rb', line 6

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/mutiny/subjects/subject.rb', line 6

def path
  @path
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/mutiny/subjects/subject.rb', line 6

def root
  @root
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==



21
22
23
# File 'lib/mutiny/subjects/subject.rb', line 21

def eql?(other)
  is_a?(other.class) && other.name == name && other.path == path && other.root == root
end

#hashObject



27
28
29
# File 'lib/mutiny/subjects/subject.rb', line 27

def hash
  [name, path, root].hash
end

#relative_pathObject



14
15
16
17
18
19
# File 'lib/mutiny/subjects/subject.rb', line 14

def relative_path
  absolute_path = Pathname.new(path)
  root_path = Pathname.new(root)

  absolute_path.relative_path_from(root_path).to_s
end