Class: Ablab::Group

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description = nil, weight = nil) ⇒ Group

Returns a new instance of Group.



206
207
208
209
# File 'lib/ablab.rb', line 206

def initialize(name, description = nil, weight = nil)
  @name, @description = name.to_sym, description
  @weight = weight || 1
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



204
205
206
# File 'lib/ablab.rb', line 204

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



204
205
206
# File 'lib/ablab.rb', line 204

def name
  @name
end

#weightObject (readonly)

Returns the value of attribute weight.



204
205
206
# File 'lib/ablab.rb', line 204

def weight
  @weight
end

Class Method Details

.controlObject



235
236
237
# File 'lib/ablab.rb', line 235

def self.control
  new(:control, 'control group')
end

Instance Method Details

#==(o) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
# File 'lib/ablab.rb', line 219

def ==(o)
  if o.is_a?(Symbol)
    name == o
  elsif o.is_a?(String)
    name.to_s == o
  elsif o.is_a?(self.class)
    name == o.name && description == o.description
  else
    false
  end
end

#control?Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/ablab.rb', line 211

def control?
  name == :control
end

#eql?Object



205
# File 'lib/ablab.rb', line 205

alias_method :eql?, :==

#experimental?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/ablab.rb', line 215

def experimental?
  !control?
end

#hashObject



231
232
233
# File 'lib/ablab.rb', line 231

def hash
  name.hash
end