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
-
#accessor ⇒ Object
readonly
A method that should be called on the characteristic in order to display it properly.
-
#measurement ⇒ Object
readonly
Specifies that the characteristic should be treated as a measured quantity.
-
#name ⇒ Object
readonly
The characteristic’s name.
-
#proc ⇒ Object
readonly
A proc, if defined, that specifies how the characteristic should be displayed.
Instance Method Summary collapse
-
#initialize(name, options, &blk) ⇒ Characteristic
constructor
Create a characteristic.
-
#measurement_class ⇒ Class
The subclass of
Charisma::Measurement
with which this curation’s characteristic is measured.
Constructor Details
#initialize(name, options, &blk) ⇒ Characteristic
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
#accessor ⇒ Object (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 |
#measurement ⇒ Object (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 |
#name ⇒ Object (readonly)
The characteristic’s name
9 10 11 |
# File 'lib/charisma/characteristic.rb', line 9 def name @name end |
#proc ⇒ Object (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
#measurement_class ⇒ 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 |