Class: WirisPlugin::SortArrayByStringLength

Inherits:
Object
  • Object
show all
Includes:
Wiris
Defined in:
lib/com/wiris/util/type/SortArrayByStringLength.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#arrayToSortObject

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

#getSortedObject



15
16
17
# File 'lib/com/wiris/util/type/SortArrayByStringLength.rb', line 15

def getSorted()
    return self.arrayToSort
end