Class: WirisPlugin::SortStringByLength
- Inherits:
-
Object
- Object
- WirisPlugin::SortStringByLength
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/type/SortStringByLength.rb
Instance Attribute Summary collapse
-
#arrayToSort ⇒ Object
Returns the value of attribute arrayToSort.
Instance Method Summary collapse
- #compare(a, b) ⇒ Object
- #getSorted ⇒ Object
-
#initialize(arrayToSort) ⇒ SortStringByLength
constructor
A new instance of SortStringByLength.
Constructor Details
#initialize(arrayToSort) ⇒ SortStringByLength
Returns a new instance of SortStringByLength.
10 11 12 13 14 |
# File 'lib/com/wiris/util/type/SortStringByLength.rb', line 10 def initialize(arrayToSort) super() self.arrayToSort = arrayToSort Arrays::sort(self.arrayToSort,self) end |
Instance Attribute Details
#arrayToSort ⇒ Object
Returns the value of attribute arrayToSort.
9 10 11 |
# File 'lib/com/wiris/util/type/SortStringByLength.rb', line 9 def arrayToSort @arrayToSort end |
Instance Method Details
#compare(a, b) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/com/wiris/util/type/SortStringByLength.rb', line 18 def compare(a, b) if a::length() < b::length() return 1 end return -1 end |
#getSorted ⇒ Object
15 16 17 |
# File 'lib/com/wiris/util/type/SortStringByLength.rb', line 15 def getSorted() return self.arrayToSort end |