Class: CiteProc::Variable
- Inherits:
-
Object
- Object
- CiteProc::Variable
- Extended by:
- Forwardable
- Includes:
- Comparable, Support::Attributes
- Defined in:
- lib/citeproc/variable.rb
Class Attribute Summary collapse
-
.date_fields ⇒ Object
readonly
Returns the value of attribute date_fields.
-
.filters ⇒ Object
readonly
Returns the value of attribute filters.
-
.name_fields ⇒ Object
readonly
Returns the value of attribute name_fields.
-
.text_fields ⇒ Object
readonly
Returns the value of attribute text_fields.
-
.types ⇒ Object
readonly
Returns the value of attribute types.
Attributes included from Support::Attributes
#attributes, #key_filter, #value_filter
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(attributes = {}) {|_self| ... } ⇒ Variable
constructor
A new instance of Variable.
- #numeric? ⇒ Boolean
- #parse!(argument) ⇒ Object
- #to_i ⇒ Object
Methods included from Support::Attributes
#[], #[]=, included, #merge, #reverse_merge
Constructor Details
#initialize(attributes = {}) {|_self| ... } ⇒ Variable
Returns a new instance of Variable.
51 52 53 54 |
# File 'lib/citeproc/variable.rb', line 51 def initialize(attributes={}, &block) parse!(attributes) yield self if block_given? end |
Class Attribute Details
.date_fields ⇒ Object (readonly)
Returns the value of attribute date_fields.
35 36 37 |
# File 'lib/citeproc/variable.rb', line 35 def date_fields @date_fields end |
.filters ⇒ Object (readonly)
Returns the value of attribute filters.
35 36 37 |
# File 'lib/citeproc/variable.rb', line 35 def filters @filters end |
.name_fields ⇒ Object (readonly)
Returns the value of attribute name_fields.
35 36 37 |
# File 'lib/citeproc/variable.rb', line 35 def name_fields @name_fields end |
.text_fields ⇒ Object (readonly)
Returns the value of attribute text_fields.
35 36 37 |
# File 'lib/citeproc/variable.rb', line 35 def text_fields @text_fields end |
.types ⇒ Object (readonly)
Returns the value of attribute types.
35 36 37 |
# File 'lib/citeproc/variable.rb', line 35 def types @types end |
Class Method Details
.fields ⇒ Object
37 38 39 |
# File 'lib/citeproc/variable.rb', line 37 def fields date_fields + name_fields + text_fields end |
Instance Method Details
#<=>(other) ⇒ Object
71 72 73 |
# File 'lib/citeproc/variable.rb', line 71 def <=>(other) strip_markup(to_s) <=> strip_markup(other.to_s) end |
#numeric? ⇒ Boolean
61 62 63 |
# File 'lib/citeproc/variable.rb', line 61 def numeric? to_s =~ /\d/ end |
#parse!(argument) ⇒ Object
56 57 58 59 |
# File 'lib/citeproc/variable.rb', line 56 def parse!(argument) argument = argument.to_hash if argument.is_a?(Variable) argument.is_a?(Hash) ? self.merge!(argument) : self.value = argument.to_s end |
#to_i ⇒ Object
66 67 68 |
# File 'lib/citeproc/variable.rb', line 66 def to_i to_s =~ /(-?\d[\d,\.]*)/ && $1.to_i || 0 end |