Class: JLDrill::Usage
- Inherits:
-
Object
- Object
- JLDrill::Usage
- Defined in:
- lib/jldrill/model/items/edict/Usage.rb
Overview
Holds a collection of definitions that defines a typical usage for the word. It also holds an index number for the usage.
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#index ⇒ Object
Returns the value of attribute index.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
-
#allDefinitions ⇒ Object
Returns all the values for the definitions.
-
#allTypes ⇒ Object
Returns all the types in the definitions.
-
#initialize ⇒ Usage
constructor
A new instance of Usage.
- #parse(string) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Usage
Returns a new instance of Usage.
13 14 15 16 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 13 def initialize @definitions = [] @index = 0 end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
10 11 12 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 10 def definitions @definitions end |
#index ⇒ Object
Returns the value of attribute index.
10 11 12 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 10 def index @index end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
10 11 12 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 10 def types @types end |
Class Method Details
Instance Method Details
#allDefinitions ⇒ Object
Returns all the values for the definitions
42 43 44 45 46 47 48 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 42 def allDefinitions retVal = [] @definitions.each do |defn| retVal.push defn.value unless defn.value == "" end retVal end |
#allTypes ⇒ Object
Returns all the types in the definitions
33 34 35 36 37 38 39 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 33 def allTypes retVal = [] @definitions.each do |defn| retVal += defn.types end retVal end |
#parse(string) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 25 def parse(string) string.split("/").each do |definition| defn = Definition.create(definition) @definitions.push(defn) end end |
#to_s ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/jldrill/model/items/edict/Usage.rb', line 50 def to_s retVal = "" if index != 0 retVal += "(" + index.to_s + ")" end retVal += @definitions.join("/") end |