Class: WirisPlugin::SortArrayByStringLength
- Inherits:
-
Object
- Object
- WirisPlugin::SortArrayByStringLength
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/type/SortArrayByStringLength.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) ⇒ SortArrayByStringLength
constructor
A new instance of SortArrayByStringLength.
Constructor Details
#initialize(arrayToSort) ⇒ SortArrayByStringLength
Returns a new instance of SortArrayByStringLength.
10 11 12 13 14 |
# File 'lib/com/wiris/util/type/SortArrayByStringLength.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/SortArrayByStringLength.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/SortArrayByStringLength.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/SortArrayByStringLength.rb', line 15 def getSorted() return self.arrayToSort end |