Class: MQ::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/mq/query.rb

Overview

Programmatic query builder for constructing mq queries in Ruby.

Examples:

Basic selector

MQ::Query.h2
# => ".h2"

Selector with filter

MQ::Query.h2.select { contains("Feature") }
# => '.h2 | select(contains("Feature"))'

Pipe operator

MQ::Query.h2 | MQ::Query.to_text
# => ".h2 | to_text()"

Attribute access

MQ::Query.link.url
# => ".link | .url"

Complex chain

MQ::Query.h2
  .select { contains("Section") & starts_with("##") }
  .to_text
# => '.h2 | select(contains("Section") and starts_with("##")) | to_text()'

Using with MQ.run

result = MQ.run(MQ::Query.h2.select { contains("Feature") }, content)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expr = "") ⇒ Query

Returns a new instance of Query.



31
32
33
# File 'lib/mq/query.rb', line 31

def initialize(expr = "")
  @expr = expr.to_s
end

Class Method Details

.alignObject



460
# File 'lib/mq/query.rb', line 460

def align      = new(".align")

.altObject



453
# File 'lib/mq/query.rb', line 453

def alt        = new(".alt")

.blockquoteObject



381
# File 'lib/mq/query.rb', line 381

def blockquote = new(".blockquote")

.checkedObject



457
# File 'lib/mq/query.rb', line 457

def checked    = new(".checked")

.codeObject

Block element selectors



379
# File 'lib/mq/query.rb', line 379

def code       = new(".code")

.code_inlineObject

Inline element selectors



399
# File 'lib/mq/query.rb', line 399

def code_inline  = new(".code_inline")

.columnObject



458
# File 'lib/mq/query.rb', line 458

def column     = new(".column")

.definitionObject



393
# File 'lib/mq/query.rb', line 393

def definition = new(".definition")

.deleteObject



388
# File 'lib/mq/query.rb', line 388

def delete     = new(".delete")

.depthObject



454
# File 'lib/mq/query.rb', line 454

def depth      = new(".depth")

.doneObject



409
# File 'lib/mq/query.rb', line 409

def done       = new(".done")

.emphasisObject



387
# File 'lib/mq/query.rb', line 387

def emphasis   = new(".emphasis")

.fenceObject



451
# File 'lib/mq/query.rb', line 451

def fence      = new(".fence")

.footnoteObject



394
# File 'lib/mq/query.rb', line 394

def footnote   = new(".footnote")

.footnote_refObject



403
# File 'lib/mq/query.rb', line 403

def footnote_ref = new(".footnote_ref")

.headingObject

Generic heading (any level)



376
# File 'lib/mq/query.rb', line 376

def heading    = new(".heading")

.hrObject



382
# File 'lib/mq/query.rb', line 382

def hr         = new(".hr")

.htmlObject



392
# File 'lib/mq/query.rb', line 392

def html       = new(".html")

.imageObject



383
# File 'lib/mq/query.rb', line 383

def image      = new(".image")

.image_refObject



402
# File 'lib/mq/query.rb', line 402

def image_ref    = new(".image_ref")

.langObject



449
# File 'lib/mq/query.rb', line 449

def lang       = new(".lang")

.levelObject



455
# File 'lib/mq/query.rb', line 455

def level      = new(".level")

.line_breakObject



404
# File 'lib/mq/query.rb', line 404

def line_break   = new(".break")


384
# File 'lib/mq/query.rb', line 384

def link       = new(".link")


401
# File 'lib/mq/query.rb', line 401

def link_ref     = new(".link_ref")

.listObject

--- List selector ---



412
# File 'lib/mq/query.rb', line 412

def list       = new(".[]")

.list_at(n) ⇒ Object

List item at a specific index: .[n]



415
416
417
# File 'lib/mq/query.rb', line 415

def list_at(n)
  new(".[#{n}]")
end

.mathObject



389
# File 'lib/mq/query.rb', line 389

def math       = new(".math")

.math_inlineObject



400
# File 'lib/mq/query.rb', line 400

def math_inline  = new(".math_inline")

.mdx_flow_expressionObject



440
# File 'lib/mq/query.rb', line 440

def mdx_flow_expression   = new(".mdx_flow_expression")

.mdx_js_esmObject



441
# File 'lib/mq/query.rb', line 441

def mdx_js_esm            = new(".mdx_js_esm")

.mdx_jsx_flow_elementObject

--- MDX selectors ---



437
# File 'lib/mq/query.rb', line 437

def mdx_jsx_flow_element  = new(".mdx_jsx_flow_element")

.mdx_jsx_text_elementObject



439
# File 'lib/mq/query.rb', line 439

def mdx_jsx_text_element  = new(".mdx_jsx_text_element")

.mdx_text_expressionObject



438
# File 'lib/mq/query.rb', line 438

def mdx_text_expression   = new(".mdx_text_expression")

.metaObject



450
# File 'lib/mq/query.rb', line 450

def meta       = new(".meta")

.node_valuesObject



448
# File 'lib/mq/query.rb', line 448

def node_values = new(".values")

.orderedObject



456
# File 'lib/mq/query.rb', line 456

def ordered    = new(".ordered")

.paragraphObject



380
# File 'lib/mq/query.rb', line 380

def paragraph  = new(".p")

.property(key) ⇒ Object

Dict property selector: ."key"



463
464
465
# File 'lib/mq/query.rb', line 463

def property(key)
  new(".\"#{key}\"")
end

.randObject



484
# File 'lib/mq/query.rb', line 484

def rand        = new("rand()")

.rand_int(min, max) ⇒ Object



486
487
488
# File 'lib/mq/query.rb', line 486

def rand_int(min, max)
  new("rand_int(#{min}, #{max})")
end

.recursiveObject

Recursive / deep selector (..)



444
# File 'lib/mq/query.rb', line 444

def recursive  = new("..")

.rowObject



459
# File 'lib/mq/query.rb', line 459

def row        = new(".row")

.select(filter = nil) { ... } ⇒ Query

Class-level select (no leading selector)

Parameters:

  • filter (Filter, String, nil) (defaults to: nil)

Yields:

Returns:



472
473
474
475
# File 'lib/mq/query.rb', line 472

def select(filter = nil, &block)
  filter_str = new.send(:resolve_filter, filter, &block)
  new("select(#{filter_str})")
end

.strongObject



386
# File 'lib/mq/query.rb', line 386

def strong     = new(".strong")

.tableObject



390
# File 'lib/mq/query.rb', line 390

def table      = new(".table")

.table_alignObject



391
# File 'lib/mq/query.rb', line 391

def table_align = new(".table_align")

.table_cell(r, c) ⇒ Object

A specific cell: .[row][col]



432
433
434
# File 'lib/mq/query.rb', line 432

def table_cell(r, c)
  new(".[#{r}][#{c}]")
end

.table_col(n) ⇒ Object

All cells in a specific column: .[][n]



427
428
429
# File 'lib/mq/query.rb', line 427

def table_col(n)
  new(".[][#{n}]")
end

.table_row(n) ⇒ Object

All cells in a specific row: .[n][]



422
423
424
# File 'lib/mq/query.rb', line 422

def table_row(n)
  new(".[#{n}][]")
end

.taskObject

Task list selectors



407
# File 'lib/mq/query.rb', line 407

def task       = new(".task")

.textObject



385
# File 'lib/mq/query.rb', line 385

def text       = new(".text")

.to_markdownObject



478
# File 'lib/mq/query.rb', line 478

def to_markdown = new("to_markdown()")

.to_textObject



477
# File 'lib/mq/query.rb', line 477

def to_text     = new("to_text()")

.todoObject



408
# File 'lib/mq/query.rb', line 408

def todo       = new(".todo")

.tomlObject



395
# File 'lib/mq/query.rb', line 395

def toml       = new(".toml")

.urlObject



452
# File 'lib/mq/query.rb', line 452

def url        = new(".url")

.uuidObject

--- Value generators (usable as query starting points) ---



481
# File 'lib/mq/query.rb', line 481

def uuid        = new("uuid()")

.uuid_v4Object



482
# File 'lib/mq/query.rb', line 482

def uuid_v4     = new("uuid_v4()")

.uuid_v7Object



483
# File 'lib/mq/query.rb', line 483

def uuid_v7     = new("uuid_v7()")

.valueObject

--- Attribute selectors (as standalone starting points) ---



447
# File 'lib/mq/query.rb', line 447

def value      = new(".value")

.yamlObject



396
# File 'lib/mq/query.rb', line 396

def yaml       = new(".yaml")

Instance Method Details

#absObject



178
# File 'lib/mq/query.rb', line 178

def abs            = pipe_with("abs()")

#add(other) ⇒ Object



78
79
80
# File 'lib/mq/query.rb', line 78

def add(other)
  pipe_with("add(#{other.inspect})")
end

#alignObject



272
# File 'lib/mq/query.rb', line 272

def align          = pipe_with(".align")

#altObject



261
# File 'lib/mq/query.rb', line 261

def alt            = pipe_with(".alt")

#ascii_downcaseObject



150
# File 'lib/mq/query.rb', line 150

def ascii_downcase = pipe_with("ascii_downcase()")

#ascii_upcaseObject



151
# File 'lib/mq/query.rb', line 151

def ascii_upcase   = pipe_with("ascii_upcase()")

#attr(name) ⇒ Object



279
280
281
# File 'lib/mq/query.rb', line 279

def attr(name)
  pipe_with("attr(#{name.inspect})")
end

#base64Object



211
# File 'lib/mq/query.rb', line 211

def base64         = pipe_with("base64()")

#base64dObject



212
# File 'lib/mq/query.rb', line 212

def base64d        = pipe_with("base64d()")

#base64urlObject



213
# File 'lib/mq/query.rb', line 213

def base64url      = pipe_with("base64url()")

#base64urldObject



214
# File 'lib/mq/query.rb', line 214

def base64urld     = pipe_with("base64urld()")

#basenameObject



231
# File 'lib/mq/query.rb', line 231

def basename       = pipe_with("basename()")

#capture(pattern) ⇒ Object



170
171
172
# File 'lib/mq/query.rb', line 170

def capture(pattern)
  pipe_with("capture(#{pattern.inspect})")
end

#ceilObject



179
# File 'lib/mq/query.rb', line 179

def ceil           = pipe_with("ceil()")

#checkedObject



269
# File 'lib/mq/query.rb', line 269

def checked        = pipe_with(".checked")

#childrenObject



93
# File 'lib/mq/query.rb', line 93

def children       = pipe_with(".children")

#coalesce(default) ⇒ Object



207
208
209
# File 'lib/mq/query.rb', line 207

def coalesce(default)
  pipe_with("coalesce(#{default.inspect})")
end

#columnObject



270
# File 'lib/mq/query.rb', line 270

def column         = pipe_with(".column")

#compactObject



87
# File 'lib/mq/query.rb', line 87

def compact        = pipe_with("compact")

#debugObject



205
# File 'lib/mq/query.rb', line 205

def debug          = pipe_with("debug")

#del(value) ⇒ Object



127
128
129
# File 'lib/mq/query.rb', line 127

def del(value)
  pipe_with("del(#{value.inspect})")
end

#depthObject



265
# File 'lib/mq/query.rb', line 265

def depth          = pipe_with(".depth")

#dirnameObject



232
# File 'lib/mq/query.rb', line 232

def dirname        = pipe_with("dirname()")

#downcaseObject



148
# File 'lib/mq/query.rb', line 148

def downcase       = pipe_with("downcase()")

#emptyObject



84
# File 'lib/mq/query.rb', line 84

def empty          = pipe_with("is_empty()")

#entriesObject



92
# File 'lib/mq/query.rb', line 92

def entries        = pipe_with("entries")

#expObject



186
# File 'lib/mq/query.rb', line 186

def exp            = pipe_with("exp()")

#explodeObject



152
# File 'lib/mq/query.rb', line 152

def explode        = pipe_with("explode()")

#extnameObject



233
# File 'lib/mq/query.rb', line 233

def extname        = pipe_with("extname()")

#fenceObject



259
# File 'lib/mq/query.rb', line 259

def fence          = pipe_with(".fence")

#firstObject



82
# File 'lib/mq/query.rb', line 82

def first          = pipe_with("first")

#flattenObject



89
# File 'lib/mq/query.rb', line 89

def flatten        = pipe_with("flatten")

#floorObject



180
# File 'lib/mq/query.rb', line 180

def floor          = pipe_with("floor()")

#from_hexObject



218
# File 'lib/mq/query.rb', line 218

def from_hex       = pipe_with("from_hex()")

#get(key) ⇒ Object



240
241
242
# File 'lib/mq/query.rb', line 240

def get(key)
  pipe_with("get(#{key.inspect})")
end

#get_titleObject



287
# File 'lib/mq/query.rb', line 287

def get_title      = pipe_with("get_title")

#get_urlObject



288
# File 'lib/mq/query.rb', line 288

def get_url        = pipe_with("get_url")

#gsub(pattern, replacement) ⇒ Object



158
159
160
# File 'lib/mq/query.rb', line 158

def gsub(pattern, replacement)
  pipe_with("gsub(#{pattern.inspect}, #{replacement.inspect})")
end

#identObject



263
# File 'lib/mq/query.rb', line 263

def ident          = pipe_with(".ident")

#implodeObject



153
# File 'lib/mq/query.rb', line 153

def implode        = pipe_with("implode()")

#index(value) ⇒ Object



119
120
121
# File 'lib/mq/query.rb', line 119

def index(value)
  pipe_with("index(#{value.inspect})")
end

#insert(idx, val) ⇒ Object



131
132
133
# File 'lib/mq/query.rb', line 131

def insert(idx, val)
  pipe_with("insert(#{idx}, #{val.inspect})")
end

#internObject



156
# File 'lib/mq/query.rb', line 156

def intern         = pipe_with("intern()")

#is_nanObject



188
# File 'lib/mq/query.rb', line 188

def is_nan         = pipe_with("is_nan()")

#item_indexObject



267
# File 'lib/mq/query.rb', line 267

def item_index     = pipe_with(".index")

#join(separator) ⇒ Object



99
100
101
# File 'lib/mq/query.rb', line 99

def join(separator)
  pipe_with("join(#{separator.inspect})")
end

#keysObject



90
# File 'lib/mq/query.rb', line 90

def keys           = pipe_with("keys")

#labelObject



264
# File 'lib/mq/query.rb', line 264

def label          = pipe_with(".label")

#langObject



257
# File 'lib/mq/query.rb', line 257

def lang           = pipe_with(".lang")

#lastObject



83
# File 'lib/mq/query.rb', line 83

def last           = pipe_with("last")

#lenObject



75
# File 'lib/mq/query.rb', line 75

def len            = pipe_with("len()")

#lengthObject



74
# File 'lib/mq/query.rb', line 74

def length         = pipe_with("len()")

#levelObject



266
# File 'lib/mq/query.rb', line 266

def level          = pipe_with(".level")

#limit(n) ⇒ Object



107
108
109
# File 'lib/mq/query.rb', line 107

def limit(n)
  pipe_with("take(#{n})")
end

#lnObject



184
# File 'lib/mq/query.rb', line 184

def ln             = pipe_with("ln()")

#log10Object



185
# File 'lib/mq/query.rb', line 185

def log10          = pipe_with("log10()")

#ltrimObject



146
# File 'lib/mq/query.rb', line 146

def ltrim          = pipe_with("ltrim()")

#map(filter = nil) { ... } ⇒ Query

Append a map() transformation.

Parameters:

  • filter (Filter, String, nil) (defaults to: nil)

    filter expression (or use block)

Yields:

Returns:



58
59
60
61
# File 'lib/mq/query.rb', line 58

def map(filter = nil, &block)
  filter_str = resolve_filter(filter, &block)
  pipe_with("map(#{filter_str})")
end

#max(other) ⇒ Object



198
199
200
# File 'lib/mq/query.rb', line 198

def max(other)
  pipe_with("max(#{other})")
end

#md5Object



215
# File 'lib/mq/query.rb', line 215

def md5            = pipe_with("md5()")

#mdx_nameObject



273
# File 'lib/mq/query.rb', line 273

def mdx_name       = pipe_with(".name")

#metaObject



258
# File 'lib/mq/query.rb', line 258

def meta           = pipe_with(".meta")

#min(other) ⇒ Object



194
195
196
# File 'lib/mq/query.rb', line 194

def min(other)
  pipe_with("min(#{other})")
end

#negate_valObject



187
# File 'lib/mq/query.rb', line 187

def negate_val     = pipe_with("negate()")

#nth(n) ⇒ Object



103
104
105
# File 'lib/mq/query.rb', line 103

def nth(n)
  pipe_with("get(#{n})")
end

#orderedObject



268
# File 'lib/mq/query.rb', line 268

def ordered        = pipe_with(".ordered")

#path_join(other) ⇒ Object



236
237
238
# File 'lib/mq/query.rb', line 236

def path_join(other)
  pipe_with("path_join(#{other.inspect})")
end

#pow(n) ⇒ Object



190
191
192
# File 'lib/mq/query.rb', line 190

def pow(n)
  pipe_with("pow(#{n})")
end

#property(key) ⇒ Object

Access a dict property by key (generates ."key" selector)



249
250
251
# File 'lib/mq/query.rb', line 249

def property(key)
  pipe_with(".\"#{key}\"")
end

#randObject



225
# File 'lib/mq/query.rb', line 225

def rand           = pipe_with("rand()")

#rand_int(min, max) ⇒ Object



227
228
229
# File 'lib/mq/query.rb', line 227

def rand_int(min, max)
  pipe_with("rand_int(#{min}, #{max})")
end

#range(n) ⇒ Object



111
112
113
# File 'lib/mq/query.rb', line 111

def range(n)
  pipe_with("range(#{n})")
end

#repeat(n) ⇒ Object



135
136
137
# File 'lib/mq/query.rb', line 135

def repeat(n)
  pipe_with("repeat(#{n})")
end

#replace(from, to) ⇒ Object



162
163
164
# File 'lib/mq/query.rb', line 162

def replace(from, to)
  pipe_with("replace(#{from.inspect}, #{to.inspect})")
end

#reverseObject



85
# File 'lib/mq/query.rb', line 85

def reverse        = pipe_with("reverse")

#rindex(value) ⇒ Object



123
124
125
# File 'lib/mq/query.rb', line 123

def rindex(value)
  pipe_with("rindex(#{value.inspect})")
end

#roundObject



181
# File 'lib/mq/query.rb', line 181

def round          = pipe_with("round()")

#rowObject



271
# File 'lib/mq/query.rb', line 271

def row            = pipe_with(".row")

#rtrimObject



147
# File 'lib/mq/query.rb', line 147

def rtrim          = pipe_with("rtrim()")

#sample(n) ⇒ Object



141
142
143
# File 'lib/mq/query.rb', line 141

def sample(n)
  pipe_with("sample(#{n})")
end

#scan(pattern) ⇒ Object



174
175
176
# File 'lib/mq/query.rb', line 174

def scan(pattern)
  pipe_with("scan(#{pattern.inspect})")
end

#select(filter = nil) { ... } ⇒ Query

Append a select() filter.

Parameters:

  • filter (Filter, String, nil) (defaults to: nil)

    filter expression (or use block)

Yields:

Returns:



48
49
50
51
# File 'lib/mq/query.rb', line 48

def select(filter = nil, &block)
  filter_str = resolve_filter(filter, &block)
  pipe_with("select(#{filter_str})")
end

#set(key, val) ⇒ Object



244
245
246
# File 'lib/mq/query.rb', line 244

def set(key, val)
  pipe_with("set(#{key.inspect}, #{val.inspect})")
end

#set_attr(name, val) ⇒ Object



283
284
285
# File 'lib/mq/query.rb', line 283

def set_attr(name, val)
  pipe_with("set_attr(#{name.inspect}, #{val.inspect})")
end

#set_check(val) ⇒ Object



290
291
292
# File 'lib/mq/query.rb', line 290

def set_check(val)
  pipe_with("set_check(#{val})")
end

#set_code_block_lang(lang) ⇒ Object



298
299
300
# File 'lib/mq/query.rb', line 298

def set_code_block_lang(lang)
  pipe_with("set_code_block_lang(#{lang.inspect})")
end

#set_list_ordered(val) ⇒ Object



302
303
304
# File 'lib/mq/query.rb', line 302

def set_list_ordered(val)
  pipe_with("set_list_ordered(#{val})")
end

#set_ref(ref) ⇒ Object



294
295
296
# File 'lib/mq/query.rb', line 294

def set_ref(ref)
  pipe_with("set_ref(#{ref.inspect})")
end

#sha256Object



216
# File 'lib/mq/query.rb', line 216

def sha256         = pipe_with("sha256()")

#sha512Object



217
# File 'lib/mq/query.rb', line 217

def sha512         = pipe_with("sha512()")

#shuffleObject



139
# File 'lib/mq/query.rb', line 139

def shuffle        = pipe_with("shuffle()")

#slice(start, stop) ⇒ Object



115
116
117
# File 'lib/mq/query.rb', line 115

def slice(start, stop)
  pipe_with("slice(#{start}, #{stop})")
end

#sortObject



86
# File 'lib/mq/query.rb', line 86

def sort           = pipe_with("sort")

#split(separator) ⇒ Object



95
96
97
# File 'lib/mq/query.rb', line 95

def split(separator)
  pipe_with("split(#{separator.inspect})")
end

#sqrtObject



183
# File 'lib/mq/query.rb', line 183

def sqrt           = pipe_with("sqrt()")

#stemObject



234
# File 'lib/mq/query.rb', line 234

def stem           = pipe_with("stem()")

#test(pattern) ⇒ Object



166
167
168
# File 'lib/mq/query.rb', line 166

def test(pattern)
  pipe_with("test(#{pattern.inspect})")
end

#titleObject



262
# File 'lib/mq/query.rb', line 262

def title          = pipe_with(".title")

#to_arrayObject



70
# File 'lib/mq/query.rb', line 70

def to_array       = pipe_with("to_array()")

#to_booleanObject



69
# File 'lib/mq/query.rb', line 69

def to_boolean     = pipe_with("to_boolean()")

#to_bytesObject



71
# File 'lib/mq/query.rb', line 71

def to_bytes       = pipe_with("to_bytes()")

#to_code(lang = nil) ⇒ Object

Convert current value to a code block with the given language.



307
308
309
# File 'lib/mq/query.rb', line 307

def to_code(lang = nil)
  lang ? pipe_with("to_code(#{lang.inspect})") : pipe_with("to_code(null)")
end

#to_code_inlineObject



311
# File 'lib/mq/query.rb', line 311

def to_code_inline = pipe_with("to_code_inline()")

#to_emObject



343
# File 'lib/mq/query.rb', line 343

def to_em          = pipe_with("to_em()")

#to_h(depth) ⇒ Object

Convert current value to a heading of the given depth (1-6).



314
315
316
# File 'lib/mq/query.rb', line 314

def to_h(depth)
  pipe_with("to_h(#{depth})")
end

#to_hexObject



219
# File 'lib/mq/query.rb', line 219

def to_hex         = pipe_with("to_hex()")

#to_hex_strObject



220
# File 'lib/mq/query.rb', line 220

def to_hex_str     = pipe_with("to_hex()")

#to_hrObject



318
# File 'lib/mq/query.rb', line 318

def to_hr          = pipe_with("to_hr()")

#to_htmlObject



66
# File 'lib/mq/query.rb', line 66

def to_html        = pipe_with("to_html()")

#to_image(url, img_alt = nil, img_title = "") ⇒ Object

Create an image node. With all three args no auto-prepend occurs. With two args the current value becomes the alt text.



332
333
334
335
336
337
338
# File 'lib/mq/query.rb', line 332

def to_image(url, img_alt = nil, img_title = "")
  if img_alt
    pipe_with("to_image(#{url.inspect}, #{img_alt.inspect}, #{img_title.inspect})")
  else
    pipe_with("to_image(#{url.inspect}, #{img_title.inspect})")
  end
end

Create a link node. With all three args no auto-prepend occurs. With two args the current value becomes the link text.



322
323
324
325
326
327
328
# File 'lib/mq/query.rb', line 322

def to_link(url, text = nil, link_title = "")
  if text
    pipe_with("to_link(#{url.inspect}, #{text.inspect}, #{link_title.inspect})")
  else
    pipe_with("to_link(#{url.inspect}, #{link_title.inspect})")
  end
end

#to_markdownObject



64
# File 'lib/mq/query.rb', line 64

def to_markdown    = pipe_with("to_markdown()")

#to_markdown_stringObject



72
# File 'lib/mq/query.rb', line 72

def to_markdown_string = pipe_with("to_markdown_string()")

#to_mathObject



340
# File 'lib/mq/query.rb', line 340

def to_math        = pipe_with("to_math()")

#to_math_inlineObject



341
# File 'lib/mq/query.rb', line 341

def to_math_inline = pipe_with("to_math_inline()")

#to_md_list(list_level) ⇒ Object

Convert current value to a list item at the given nesting level.



347
348
349
# File 'lib/mq/query.rb', line 347

def to_md_list(list_level)
  pipe_with("to_md_list(#{list_level})")
end

#to_md_name(node_name) ⇒ Object

Convert current value to a markdown element with the given node name.



352
353
354
# File 'lib/mq/query.rb', line 352

def to_md_name(node_name)
  pipe_with("to_md_name(#{node_name.inspect})")
end

#to_md_table_cell(content, r, c) ⇒ Object

Build a table cell with content, row index, and column index.



362
363
364
# File 'lib/mq/query.rb', line 362

def to_md_table_cell(content, r, c)
  pipe_with("to_md_table_cell(#{content.inspect}, #{r}, #{c})")
end

#to_md_table_row(*cells) ⇒ Object

Build a table row from the given cell values.



357
358
359
# File 'lib/mq/query.rb', line 357

def to_md_table_row(*cells)
  pipe_with("to_md_table_row(#{cells.map(&:inspect).join(', ')})")
end

#to_md_textObject



344
# File 'lib/mq/query.rb', line 344

def to_md_text     = pipe_with("to_md_text()")

#to_mdxObject



65
# File 'lib/mq/query.rb', line 65

def to_mdx         = pipe_with("to_mdx()")

#to_numberObject



68
# File 'lib/mq/query.rb', line 68

def to_number      = pipe_with("to_number()")

#to_queryString Also known as: to_s

Returns the mq query string.

Returns:

  • (String)


368
# File 'lib/mq/query.rb', line 368

def to_query = @expr

#to_stringObject



67
# File 'lib/mq/query.rb', line 67

def to_string      = pipe_with("to_string()")

#to_strongObject



342
# File 'lib/mq/query.rb', line 342

def to_strong      = pipe_with("to_strong()")

#to_textObject



63
# File 'lib/mq/query.rb', line 63

def to_text        = pipe_with("to_text()")

#trimObject



145
# File 'lib/mq/query.rb', line 145

def trim           = pipe_with("trim()")

#truncObject



182
# File 'lib/mq/query.rb', line 182

def trunc          = pipe_with("trunc()")

#typeObject

--- Type / logic ---



204
# File 'lib/mq/query.rb', line 204

def type           = pipe_with("type")

#uniqObject



88
# File 'lib/mq/query.rb', line 88

def uniq           = pipe_with("uniq")

#upcaseObject



149
# File 'lib/mq/query.rb', line 149

def upcase         = pipe_with("upcase()")

#update(content) ⇒ Object



275
276
277
# File 'lib/mq/query.rb', line 275

def update(content)
  pipe_with("update(#{content.inspect})")
end

#urlObject



260
# File 'lib/mq/query.rb', line 260

def url            = pipe_with(".url")

#url_decodeObject



155
# File 'lib/mq/query.rb', line 155

def url_decode     = pipe_with("url_decode()")

#url_encodeObject



154
# File 'lib/mq/query.rb', line 154

def url_encode     = pipe_with("url_encode()")

#utf8bytelenObject



76
# File 'lib/mq/query.rb', line 76

def utf8bytelen    = pipe_with("utf8bytelen()")

#uuidObject



222
# File 'lib/mq/query.rb', line 222

def uuid           = pipe_with("uuid()")

#uuid_v4Object



223
# File 'lib/mq/query.rb', line 223

def uuid_v4        = pipe_with("uuid_v4()")

#uuid_v7Object



224
# File 'lib/mq/query.rb', line 224

def uuid_v7        = pipe_with("uuid_v7()")

#valueObject

Attribute selectors (access attributes of selected nodes) These generate attribute selector syntax (.url, .lang, etc.)



256
# File 'lib/mq/query.rb', line 256

def value          = pipe_with(".value")

#valuesObject



91
# File 'lib/mq/query.rb', line 91

def values         = pipe_with("values")

#|(other) ⇒ Query

Pipe two queries together using the | operator.

Parameters:

Returns:



39
40
41
# File 'lib/mq/query.rb', line 39

def |(other)
  self.class.new("#{@expr} | #{other.to_query}")
end