Module: Qig

Defined in:
lib/qig.rb,
lib/qig/version.rb,
lib/qig/qiggable.rb

Overview

Combining the powers of dig and jq. Qig is dig extended with jq's value iteration [] operator.

Defined Under Namespace

Modules: Qiggable

Constant Summary collapse

VERSION =
'0.4.0'

Class Method Summary collapse

Class Method Details

.qig(subject, *path) ⇒ Object+

Returns the value(s) of subject located at path.

Parameters:

  • subject (Array, Hash, #[])

    subject to be qug into.

  • path (Array<String, Symbol, Array, Object>)

    retrieval path to apply to subject

Returns:

  • (Object, Array<Object>)

    the value(s) of subject located at path



15
16
17
# File 'lib/qig.rb', line 15

def qig(subject, *path)
  unit_qig(subject, *path)
end

.values(arrayish) ⇒ Array, Object

"values" as in jq's "value iterator".

Coerce to array by taking the .values. Intuitively, get all possible values of arrayish[x].

Parameters:

  • arrayish (Array, Hash, #values, Object)

    array or hash or other to coerce to values

Returns:

  • (Array, Array, Array, Object)

    array of coerced values



25
26
27
# File 'lib/qig.rb', line 25

def values(arrayish)
  arrayish.respond_to?(:values) ? arrayish.values : arrayish
end