HighDots Forums  

mini_magick - 2 clarifications

Ruby On Rails Talk Ruby On Rails programming language mailing list


Discuss mini_magick - 2 clarifications in the Ruby On Rails Talk forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
doug
 
Posts: n/a

Default mini_magick - 2 clarifications - 11-05-2009 , 10:46 PM






1. I have seen examples similar to the following:

image = MiniMagick::Image.from_file("input.jpg")
image.resize "100x100"
image.write("output.jpg")

I'm assuming that image.resize is a method. Is there any significance
to the fact that the argument for that method is not enclosed in
parenthesis while the other are? Examples seem to be consistent --
way too consistent for coincidence.

2. When I resize an image, is there a way to do that operation in
place so that I don't have to write it out to a different file,
conceptually like:

image.resize! "100x100"

Thanks for any input.

... doug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #2  
Old   
Rick
 
Posts: n/a

Default Re: mini_magick - 2 clarifications - 11-07-2009 , 09:34 AM






Paren use is optional except when required to disambiguate, i.e. when
method1 takes two args and the first is method2 (which takes one or
two args) you would use parens to group method2's args.

It's a Ruby thing. Can be tough to get used to if you're coming from
a c background and are used to the visual cue that parens provide.

On Nov 5, 10:46*pm, doug <ddjol... (AT) gmail (DOT) com> wrote:
Quote:
1. *I have seen examples similar to the following:

* image = MiniMagick::Image.from_file("input.jpg")
* image.resize "100x100"
* image.write("output.jpg")

I'm assuming that image.resize is a method. *Is there any significance
to the fact that the argument for that method is not enclosed in
parenthesis while the other are? *Examples seem to be consistent --
way too consistent for coincidence.

2. *When I resize an image, is there a way to do that operation in
place so that I don't have to write it out to a different file,
conceptually like:

* * *image.resize! "100x100"

Thanks for any input.

* * * * *... doug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #3  
Old   
doug
 
Posts: n/a

Default Re: mini_magick - 2 clarifications - 11-07-2009 , 06:36 PM



Quote:
It's a Ruby thing. *Can be tough to get used to
Yep. I understand and definitely agree that it's a bit tough to get
used to. The thing is, when the option to use parens when they're not
required is exercised (as in lines 1 and 3 of this example) and then,
for no apprent reason, the option is not exercised in the intervening
line 2, it leaves me to wonder if the author of the code knows
something that I don't. Hence the question.

Thanks for the response.

... doug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.