Class: Undies::NamedSource

Inherits:
Object
  • Object
show all
Defined in:
lib/undies/named_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ NamedSource

Returns a new instance of NamedSource.



9
10
11
12
# File 'lib/undies/named_source.rb', line 9

def initialize(*args, &block)
  args << block if block
  self.args = args
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/undies/named_source.rb', line 7

def file
  @file
end

#optsObject

Returns the value of attribute opts.



7
8
9
# File 'lib/undies/named_source.rb', line 7

def opts
  @opts
end

#procObject

Returns the value of attribute proc.



7
8
9
# File 'lib/undies/named_source.rb', line 7

def proc
  @proc
end

Instance Method Details

#==(other_named_source) ⇒ Object



14
15
16
17
18
# File 'lib/undies/named_source.rb', line 14

def ==(other_named_source)
  self.file == other_named_source.file &&
  self.opts == other_named_source.opts &&
  self.proc == other_named_source.proc
end

#argsObject



28
29
30
# File 'lib/undies/named_source.rb', line 28

def args
  [self.file, self.opts, self.proc]
end

#args=(values) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/undies/named_source.rb', line 20

def args=(values)
  self.proc, self.opts, self.file = [
    values.last.kind_of?(::Proc)   ? values.pop : nil,
    values.last.kind_of?(::Hash)   ? values.pop : {},
    values.last.kind_of?(::String) ? values.pop : nil
  ]
end