Module: Crawdad::Tokens

Extended by:
FFI::Library
Included in:
Paragraph, PrawnTokenizer
Defined in:
lib/crawdad/tokens.rb,
lib/crawdad/ffi/tokens.rb

Defined Under Namespace

Classes: Box, Glue, Penalty

Constant Summary collapse

Type =
enum(:box, :glue, :penalty)

Instance Method Summary collapse

Instance Method Details

#box(width, content) ⇒ Object



10
11
12
# File 'lib/crawdad/tokens.rb', line 10

def box(width, content)
  [:box, width, content]
end

#box_content(b) ⇒ Object



14
15
16
# File 'lib/crawdad/tokens.rb', line 14

def box_content(token)
  token[2]
end

#glue(width, stretch, shrink) ⇒ Object



18
19
20
# File 'lib/crawdad/tokens.rb', line 18

def glue(width, stretch, shrink)
  [:glue, width, stretch, shrink]
end

#glue_shrink(glue) ⇒ Object



26
27
28
# File 'lib/crawdad/tokens.rb', line 26

def glue_shrink(token)
  token[3]
end

#glue_stretch(glue) ⇒ Object



22
23
24
# File 'lib/crawdad/tokens.rb', line 22

def glue_stretch(token)
  token[2]
end

#penalty(penalty, width = 0.0, flagged = false) ⇒ Object



30
31
32
# File 'lib/crawdad/tokens.rb', line 30

def penalty(penalty, width=0, flagged=false)
  [:penalty, width, penalty, flagged]
end

#penalty_flagged?(p) ⇒ Boolean

TODO: this might return true/false. problem?

Returns:

  • (Boolean)


75
76
77
# File 'lib/crawdad/ffi/tokens.rb', line 75

def penalty_flagged?(token)
  token[3]
end

#penalty_penalty(p) ⇒ Object



34
35
36
# File 'lib/crawdad/tokens.rb', line 34

def penalty_penalty(token)
  token[2]
end

#token_type(token) ⇒ Object



6
7
8
# File 'lib/crawdad/tokens.rb', line 6

def token_type(token)
  token[0]
end

#token_width(token) ⇒ Object



42
43
44
# File 'lib/crawdad/tokens.rb', line 42

def token_width(token)
  token[1]
end