Class: Sortah::Destination

Inherits:
Object
  • Object
show all
Defined in:
lib/sortah/components/destination.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path) ⇒ Destination

Returns a new instance of Destination.



22
23
24
25
# File 'lib/sortah/components/destination.rb', line 22

def initialize(name, path)
  @name = name
  @path = if path.class == Hash then path[:abs] else path end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/sortah/components/destination.rb', line 16

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/sortah/components/destination.rb', line 16

def path
  @path
end

Class Method Details

.dynamic(path) ⇒ Object



18
19
20
# File 'lib/sortah/components/destination.rb', line 18

def self.dynamic(path)
  Destination.new(nil, path)
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
38
39
# File 'lib/sortah/components/destination.rb', line 35

def ==(other)
  (other.class == Destination && other.name == @name && other.path == @path) ||
  @path == other || 
  super
end

#alias?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/sortah/components/destination.rb', line 31

def alias?
  @path.class == Symbol
end

#defined?(context) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/sortah/components/destination.rb', line 27

def defined?(context)
  context.include?(@name)
end

#to_sObject



41
42
43
# File 'lib/sortah/components/destination.rb', line 41

def to_s
  @path
end