Class: Mo2tex::Pic::Counter
- Inherits:
-
Object
- Object
- Mo2tex::Pic::Counter
- Includes:
- Singleton
- Defined in:
- lib/mo2tex/pic.rb
Instance Attribute Summary collapse
-
#cntr ⇒ Object
readonly
Returns the value of attribute cntr.
-
#pg ⇒ Object
readonly
Returns the value of attribute pg.
-
#slot ⇒ Object
readonly
Returns the value of attribute slot.
Instance Method Summary collapse
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #next_cntr ⇒ Object
- #next_pg ⇒ Object
- #next_slot ⇒ Object
- #prev_cntr(back = 1) ⇒ Object
- #prev_pg ⇒ Object
- #prev_slot(back = 1) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
19 20 21 |
# File 'lib/mo2tex/pic.rb', line 19 def initialize self.reset end |
Instance Attribute Details
#cntr ⇒ Object (readonly)
Returns the value of attribute cntr.
15 16 17 |
# File 'lib/mo2tex/pic.rb', line 15 def cntr @cntr end |
#pg ⇒ Object (readonly)
Returns the value of attribute pg.
15 16 17 |
# File 'lib/mo2tex/pic.rb', line 15 def pg @pg end |
#slot ⇒ Object (readonly)
Returns the value of attribute slot.
15 16 17 |
# File 'lib/mo2tex/pic.rb', line 15 def slot @slot end |
Instance Method Details
#next_cntr ⇒ Object
31 32 33 |
# File 'lib/mo2tex/pic.rb', line 31 def next_cntr return nxt(:cntr) end |
#next_pg ⇒ Object
27 28 29 |
# File 'lib/mo2tex/pic.rb', line 27 def next_pg return nxt(:pg) end |
#next_slot ⇒ Object
35 36 37 |
# File 'lib/mo2tex/pic.rb', line 35 def next_slot return nxt(:slot) end |
#prev_cntr(back = 1) ⇒ Object
43 44 45 |
# File 'lib/mo2tex/pic.rb', line 43 def prev_cntr(back = 1) return self.cntr == 0 ? self.cntr : self.cntr-back end |
#prev_pg ⇒ Object
39 40 41 |
# File 'lib/mo2tex/pic.rb', line 39 def prev_pg return self.pg == 0 ? self.pg : self.pg-1 end |
#prev_slot(back = 1) ⇒ Object
47 48 49 |
# File 'lib/mo2tex/pic.rb', line 47 def prev_slot(back = 1) return self.slot == 0 ? self.slot : self.slot-back end |
#reset ⇒ Object
23 24 25 |
# File 'lib/mo2tex/pic.rb', line 23 def reset @pg = @cntr = @slot = 0 end |