Class: Docks::Descriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/docks/descriptor.rb

Constant Summary collapse

PATTERN =
/^([^:]*)::/
INSTANCE_MEMBER =
/#(.*)/
STATIC_MEMBER =
/\.(.*)/
LOCAL_MEMBER =
/~(.*)/
MEMBERS =
[:instance_member, :static_member, :local_member]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(descriptor_string, options) ⇒ Descriptor

Returns a new instance of Descriptor.



16
17
18
# File 'lib/docks/descriptor.rb', line 16

def initialize(descriptor_string, options)
  parse(descriptor_string, options)
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



9
10
11
# File 'lib/docks/descriptor.rb', line 9

def pattern
  @pattern
end

#symbolObject (readonly)

Returns the value of attribute symbol.



9
10
11
# File 'lib/docks/descriptor.rb', line 9

def symbol
  @symbol
end

Class Method Details

.new(descriptor_string, options = {}) ⇒ Object



12
13
14
# File 'lib/docks/descriptor.rb', line 12

def self.new(descriptor_string, options = {})
  descriptor_string.kind_of?(self) ? descriptor_string : super
end

Instance Method Details

#memberObject



24
25
26
27
28
29
30
31
# File 'lib/docks/descriptor.rb', line 24

def member
  MEMBERS.each do |member_type|
    member = self.send(member_type)
    return member unless member.nil?
  end

  nil
end

#member?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/docks/descriptor.rb', line 20

def member?
  MEMBERS.any? { |member_type| !self.send(member_type).nil? }
end