class Sequel::Postgres::InetOp

  1. lib/sequel/extensions/pg_inet_ops.rb
Superclass: Sequel::SQL::Wrapper

The InetOp class is a simple container for a single object that defines methods that yield Sequel expression objects representing PostgreSQL inet operators and functions.

Most methods in this class are defined via metaprogramming, see the pg_inet_ops extension documentation for details on the API.

Methods

Public Class

  1. new

Public Instance

  1. -
  2. pg_inet
  3. set_masklen
  4. ~

Included modules

  1. Sequel::SQL::BitwiseMethods

Constants

OPERATORS = { :contained_by_or_equals => ["(".freeze, " <<= ".freeze, ")".freeze].freeze, :contains_or_equals => ["(".freeze, " >>= ".freeze, ")".freeze].freeze, :contains_or_contained_by => ["(".freeze, " && ".freeze, ")".freeze].freeze, }.freeze  

Public Class methods

new(v)

For String and IPAddr instances, wrap them in a cast to inet, to avoid ambiguity issues when calling operator methods.

[show source]
   # File lib/sequel/extensions/pg_inet_ops.rb
77 def initialize(v)
78   case v
79   when ::Sequel::LiteralString
80     # nothing
81   when String, IPAddr
82     v = Sequel.cast(v, :inet)
83   end
84   super
85 end

Public Instance methods

-(v)

Return an expression for the subtraction of the argument from the receiver

[show source]
    # File lib/sequel/extensions/pg_inet_ops.rb
128 def -(v)
129   case v
130   when Integer
131     self.class.new(super)
132   else
133     Sequel::SQL::NumericExpression.new(:NOOP, super)
134   end
135 end
pg_inet()

Return the receiver.

[show source]
    # File lib/sequel/extensions/pg_inet_ops.rb
118 def pg_inet
119   self
120 end
set_masklen(v)

Return an expression for the calling of the set_masklen function with the receiver and the given argument

[show source]
    # File lib/sequel/extensions/pg_inet_ops.rb
138 def set_masklen(v)
139   self.class.new(Sequel::SQL::Function.new(:set_masklen, self, v))
140 end
~()

Return an expression for the bitwise NOT of the receiver

[show source]
    # File lib/sequel/extensions/pg_inet_ops.rb
123 def ~
124   self.class.new(super)
125 end