Module: Lab42::NHash::Afixes
- Included in:
- Lab42::NHash
- Defined in:
- lib/lab42/nhash/affixes.rb
Instance Method Summary collapse
- #current_prefix ⇒ Object
- #current_suffix ⇒ Object
- #pop_prefix ⇒ Object
- #pop_suffix ⇒ Object
- #push_prefix(pfx) ⇒ Object
- #push_suffix(sfx) ⇒ Object
- #with_affixes(pfx, sfx, &blk) ⇒ Object
- #with_prefix(pfx, &blk) ⇒ Object
- #with_suffix(sfx, &blk) ⇒ Object
Instance Method Details
#current_prefix ⇒ Object
11 12 13 14 15 |
# File 'lib/lab42/nhash/affixes.rb', line 11 def current_prefix @prefix_stack .fetch( -1, '' ) .split( '.' ) end |
#current_suffix ⇒ Object
17 18 19 20 21 |
# File 'lib/lab42/nhash/affixes.rb', line 17 def current_suffix @suffix_stack .fetch( -1, '' ) .split( '.' ) end |
#pop_prefix ⇒ Object
6 |
# File 'lib/lab42/nhash/affixes.rb', line 6 def pop_prefix; @prefix_stack.pop; self end |
#pop_suffix ⇒ Object
7 |
# File 'lib/lab42/nhash/affixes.rb', line 7 def pop_suffix; @suffix_stack.pop; self end |
#push_prefix(pfx) ⇒ Object
8 |
# File 'lib/lab42/nhash/affixes.rb', line 8 def push_prefix pfx; @prefix_stack.push pfx.to_s; self end |
#push_suffix(sfx) ⇒ Object
9 |
# File 'lib/lab42/nhash/affixes.rb', line 9 def push_suffix sfx; @suffix_stack.push sfx.to_s; self end |
#with_affixes(pfx, sfx, &blk) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/lab42/nhash/affixes.rb', line 23 def with_affixes pfx, sfx, &blk push_prefix pfx push_suffix sfx _invoke blk, self ensure pop_prefix pop_suffix end |
#with_prefix(pfx, &blk) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/lab42/nhash/affixes.rb', line 32 def with_prefix pfx, &blk push_prefix pfx _invoke blk, self ensure pop_prefix end |
#with_suffix(sfx, &blk) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lab42/nhash/affixes.rb', line 39 def with_suffix sfx, &blk push_suffix sfx _invoke blk, self ensure pop_suffix end |