diminish7 / rave

A Google Wave robot client framework for Ruby
http://github.com/diminish7/rave
MIT License
62 stars 8 forks source link

Allow access to document operations in Ruby way #12

Open bil-bas opened 14 years ago

bil-bas commented 14 years ago

Blip.text[1..3] = '' (delete in range) Blip.text[1..3] = 'Frog' (set in range) Blip.text[5] = ?a (via set in range) Blip.text.sub!(/frog/, "Fish") (via set in range) Blip.text[/frog/] = "Fish" (same as sub!) Blip.text.gsub!(/frog/, "Fish") (via set in range) Blip.text.append("Fish") (via append_text) Blip.text << "Fish" (as append) Blip.text = 'Frog' (set text) Blip.text = '' (clear) Blip.text.insert(5, '') (insert text - note that the standard Ruby string way to insert text has reversed paramters to that of insert_text as implemented; I think keeping things the same as Ruby is best, since the alternative order is just arbitrary choice by Python dev)

bil-bas commented 14 years ago

I've reversed the order of the insert_text() function because it was irritating me. Not sure how important the other things are; it is mainly the effort of generating the tests that is putting me off really ;)

bil-bas commented 14 years ago

These are probably less useful than I expected, since it makes more sense to can use HTML/textile to write to the blip (well, set_text and append_text work this way).

Incidentally, the problem we have with inserting text can probably be fixed once we work out the syntax for DOCUMENT_REPLACE, but since you only get to add a string and a start location for that, I'm not sure how useful it would be compared to a "real" replace in range. Couldn't get it to do anything at all when I tried it, which was a pain. Don't know if it isn't implemented at their end or my operation packet is wrong.