Class: Charisma::Characteristic
- Inherits:
-
Object
- Object
- Charisma::Characteristic
- Defined in:
- lib/charisma/characteristic.rb
Overview
Stores information about a characteristic.
Typically these are defined with Charisma::Characterization#has in a characterize do . . . end block.
Instance Attribute Summary (collapse)
-
- (Object) accessor
readonly
A method that should be called on the characteristic in order to display it properly.
-
- (Object) measurement
readonly
Specifies that the characteristic should be treated as a measured quantity.
-
- (Object) name
readonly
The characteristic's name.
-
- (Object) proc
readonly
A proc, if defined, that specifies how the characteristic should be displayed.
Instance Method Summary (collapse)
-
- (Characteristic) initialize(name, options, &blk)
constructor
Create a characteristic.
-
- (Class) measurement_class
The subclass of Charisma::Measurement with which this curation's characteristic is measured.
Constructor Details
- (Characteristic) initialize(name, options, &blk)
Create a characteristic.
Typically this is done via Charisma::Characterization#has within a characterize do . . . end block.
31 32 33 34 35 36 |
# File 'lib/charisma/characteristic.rb', line 31 def initialize(name, , &blk) @name = name @proc = blk if block_given? @accessor = [:display_with] @measurement = [:measures] end |
Instance Attribute Details
- (Object) accessor (readonly)
A method that should be called on the characteristic in order to display it properly
15 16 17 |
# File 'lib/charisma/characteristic.rb', line 15 def accessor @accessor end |
- (Object) measurement (readonly)
Specifies that the characteristic should be treated as a measured quantity
18 19 20 |
# File 'lib/charisma/characteristic.rb', line 18 def measurement @measurement end |
- (Object) name (readonly)
The characteristic's name
9 10 11 |
# File 'lib/charisma/characteristic.rb', line 9 def name @name end |
- (Object) proc (readonly)
A proc, if defined, that specifies how the characteristic should be displayed
12 13 14 |
# File 'lib/charisma/characteristic.rb', line 12 def proc @proc end |
Instance Method Details
- (Class) measurement_class
The subclass of Charisma::Measurement with which this curation's characteristic is measured.
40 41 42 43 44 45 46 47 |
# File 'lib/charisma/characteristic.rb', line 40 def measurement_class case measurement when ::Class measurement when ::Symbol "::Charisma::Measurement::#{measurement.to_s.camelize}".constantize end end |