Class: RCite::Element
- Inherits:
-
Object
- Object
- RCite::Element
- Defined in:
- lib/rcite/element.rb
Overview
Represents one element of a citation. An element can be either some sort
of content, f.ex. the surname of an author, or a separator like " " or
", ". This distinction is made so that one can add content and separators
without knowing whether the content will actually exist, and later omit
separators that are meant to seperate content that doesn't exist.
Instance Attribute Summary (collapse)
-
- (String) content
The element's content, for example an author's surname or a separator like
", ". -
- (Symbol) type
The element type.
Instance Method Summary (collapse)
-
- (Boolean) ==(other_element)
Checks if this element is equal to
other_element. -
- (Element) initialize(type, content)
constructor
A new instance of Element.
-
- (String) to_s
Returns a human-readable string representation of the Element.
Constructor Details
- (Element) initialize(type, content)
A new instance of Element
17 18 19 20 |
# File 'lib/rcite/element.rb', line 17 def initialize(type, content) @type = type @content = content end |
Instance Attribute Details
- (String) content
The element's content, for example an author's surname or
a separator like ", ".
15 16 17 |
# File 'lib/rcite/element.rb', line 15 def content @content end |
- (Symbol) type
The element type. Only :sep (for separators) and :con
(for content) are allowed. See RCite::Element for details.
12 13 14 |
# File 'lib/rcite/element.rb', line 12 def type @type end |
Instance Method Details
- (Boolean) ==(other_element)
Checks if this element is equal to other_element.
36 37 38 39 40 41 |
# File 'lib/rcite/element.rb', line 36 def ==(other_element) if other_element.type == type && other_element.content == content return true end return false end |
- (String) to_s
Returns a human-readable string representation of the Element.
46 47 48 |
# File 'lib/rcite/element.rb', line 46 def to_s "[#{@type}]#{@content}" end |