Class: Arrow::SortKey
- Inherits:
-
Object
- Object
- Arrow::SortKey
- Defined in:
- lib/arrow/sort-key.rb,
lib/arrow/jruby/sort-key.rb
Class Method Summary collapse
-
.resolve(target, order = nil, null_placement = nil) ⇒ Object
Ensure returning suitable SortKey.
- .try_convert(value) ⇒ Object private
Instance Method Summary collapse
-
#initialize(target, order = nil, null_placement = nil) ⇒ SortKey
constructor
Creates a new SortKey.
-
#name ⇒ Object
For backward compatibility.
- #target ⇒ Object
-
#to_s ⇒ String
The string representation of this sort key.
Constructor Details
#initialize(target) ⇒ SortKey #initialize(target, order) ⇒ SortKey #initialize(target, order, null_placement) ⇒ SortKey
Creates a new Arrow::SortKey.
177 178 179 180 181 182 |
# File 'lib/arrow/sort-key.rb', line 177 def initialize(target, order=nil, null_placement=nil) target, order, null_placement = normalize_target(target, order, null_placement) order = normalize_order(order) || :ascending null_placement = normalize_null_placement(null_placement) || :at_end initialize_raw(target, order, null_placement) end |
Class Method Details
.resolve(sort_key) ⇒ Arrow::SortKey .resolve(target) ⇒ Arrow::SortKey .resolve(target, order) ⇒ Arrow::SortKey
Ensure returning suitable Arrow::SortKey.
49 50 51 52 |
# File 'lib/arrow/sort-key.rb', line 49 def resolve(target, order=nil, null_placement=nil) return target if target.is_a?(self) new(target, order, null_placement) end |
.try_convert(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 58 59 60 61 62 |
# File 'lib/arrow/sort-key.rb', line 55 def try_convert(value) case value when Symbol, String new(value.to_s, :ascending, :at_end) else nil end end |
Instance Method Details
#name ⇒ Object
For backward compatibility
211 |
# File 'lib/arrow/sort-key.rb', line 211 alias_method :name, :target |
#target ⇒ Object
20 21 22 |
# File 'lib/arrow/jruby/sort-key.rb', line 20 def target raise NotImplementedError end |
#to_s ⇒ String
Returns The string representation of this sort key. You
can use recreate Arrow::SortKey by
Arrow::SortKey.new(key.to_s).
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/arrow/sort-key.rb', line 194 def to_s result = "" if order == SortOrder::ASCENDING result += "+" else result += "-" end if null_placement == NullPlacement::AT_START result += "^" else result += "$" end result += target result end |