rdoc for date.rb doesn't distinguish instance methods

ruby

    Next

  • 1. Gem error on "require 'rubygems'"
    Hello RubyComminity !!!! I have decided to move to ruby to make the util script I usually do in Perl. I need to create a graph from an XML file. For this, it seems that I can use gruff and magic/xml (not sure this is the best choice as I am not familiar with those libs). I have installed the gruff gem, that went fine. Regarding magic/xml I have unzip the install and copy the folder in "C:\ruby\lib\ruby\1.8" (is that enought ???) Then I tried the gruff example: ------ #!/usr/bin/ruby require 'rubygems' require 'gruff' g = Gruff::Line.new g.title = "My Graph" g.data("Apples", [1, 2, 3, 4, 4, 3]) g.data("Oranges", [4, 8, 7, 9, 8, 9]) g.data("Watermelon", [2, 3, 1, 5, 6, 8]) g.data("Peaches", [9, 9, 10, 8, 7, 9]) g.labels = {0 => '2003', 2 => '2004', 4 => '2005'} g.write('my_fruity_graph.png') ------- But I get the following error..... Gem::LoadError: Could not find RubyGem hoe (>= 1.1.2) Do you have an idea of what went wrong ? Also, I have to install all the gem locally as I am behind a proxy (do not know if this can be linked) Thanks a lot, Luc
  • 2. downcase part of a string
    hi, I want to downcase a string but without specific parts. for example: msg = "THIS is a Text and (NO Change HERE) HELP" after downcase it should look like "this is a text and (NO Change HERE) help" I don't want to downcase the letters in parentheses. How can i do that, i tried it with regular expressions but can't do it. Thanks for any help
  • 3. Using another program (Lynx) from within Ruby
    I'm trying to write a script to read a list of URLS, get the HTTP response headers and <title> (if there is a page there) from each URL, and output to a CSV file in this format: URL, header, <title> I've started with something like this, using Lynx to get the headers. The part that doesn't seem to work is this: `lynx -dump -head "#{line}"` -- it doesn't want to put the url into the #{line} within the backticks. How do you insert a variable from Ruby into the shell command? I'm ordering 4 Ruby books by mail today... I haven't seen anything like this in the ones that I've browsed though. Here is a larger section of the script: print "Enter the location of the input file: " infile = gets.chomp # open file File.open(infile, "r") do |f| # get HTTP headers with Lynx output = f.each_line { |line| `lynx -dump -head "#{line}" | grep "HTTP"` } # puts output to CVS file # TODO

rdoc for date.rb doesn't distinguish instance methods

Postby Lloyd Zusman » Mon, 07 Feb 2005 09:04:16 GMT

I'm not sure how long this has been going on, but I just noticed it
today:  the rdoc that gets generated for date.rb from the latest
CVS doesn't show a "Public instance methods" section ... all methods
are listed as "Public class methods", which is clearly incorrect.

This is forcing me to use the code iself as documentation in some work
I'm doing that involves subclassing the "DateTime" class.

What needs to be done inside of date.rb to cause the rdoc's to be
generated with the "Public instance methods" header?  I'd like to put
the appropriate tags into that file and re-run the rdoc, so that I can
have some more useful documentation for the Date class.

Thanks in advance.

-- 
 Lloyd Zusman
  XXXX@XXXXX.COM 
 God bless you.




Similar Threads:

1.Set doesn't have [] instance method

It should, shouldn't it?  It's meant to combine the fast lookup of
Hash with the convenience of Array, yet the most important method Hash
and Array have in common, Set lacks!

$ irb
irb(main):001:0> require 'set'
=> true
irb(main):002:0> s = Set[1,2,3]
=> #<Set: {1, 2, 3}>
irb(main):003:0> s.include? 1
=> true
irb(main):004:0> s[1]
NoMethodError: undefined method `[]' for #<Set: {1, 2, 3}>
        from (irb):4
        from :0


This would be a good thing to fix before 1.8 is released.

Gavin


2.Set doesn't have [] instance method - and Set#| is inconsistent with Set#&

On Sunday, July 27, 2003, 3:28:06 AM, Gavin wrote:

> It should, shouldn't it?  It's meant to combine the fast lookup of
> Hash with the convenience of Array, yet the most important method Hash
> and Array have in common, Set lacks!
> [...]

Oh well, judging by the responses, I guess it's not all that sensible
after all.

I just don't like typing "include?" for something as simple as a lookup,
especially when Set (to my mind) is just a special case of Hash --
with a bit more thrown in.  Also since "include?" is bad grammar.

Another question, then.  Why does Set#| return a Set, but Set#&
returns an Array?

Gavin


3.Method equality; setting instance variables on Method instances

A few questions about the code below:
1) Why do m1 and m2 have different IDs but compare as equal?
2) Why does m2 invoke the same old functionality when run?
3) Why did my instance_variable_set not 'take'?

I suspect all answers have something to do with where the methods are
being defined/shadowed, but I'll be damned if I can figure them out.

slim:~/Desktop/test gavinkistner$ ls -Flag
total 8
drwxr-xr-x    3 staff   102 Dec 24 10:15 ./
drwx------   34 staff  1156 Dec 24 10:15 ../
-rw-r--r--    1 staff   734 Dec 24 10:20 override.rb


slim:~/Desktop/test gavinkistner$ cat override.rb
class Module
        def override( method_name, &block )
          orig_method = method( method_name )
          new_name = "m#{rand(1000000000)}"
                alias_method new_name, method_name
          define_method( method_name, &block )
    method( method_name ).instance_variable_set( :@__orig_method_name,
new_name )
  end

   def restore( method_name )
     alias_method method_name, method( method_name
).instance_variable_get( :@__orig_method_name )
   end
end

m1 = Kernel.method( :system )
system 'ls'

Kernel.override( :system ){ |code| puts "`#{code}` not allowed"}
m2 = Kernel.method( :system )
system 'ls'

p m1, m2, m1==m2, m1.object_id, m2.object_id
m1.call( 'ls' )
m2.call( 'ls' )

Kernel.restore( :system )
m3 = Kernel.method( :system )
system 'ls'

__END__


slim:~/Desktop/test gavinkistner$ ruby override.rb
override.rb
`ls` not allowed
#<Method: Kernel.system>
#<Method: Kernel.system>
true
953400
953250
override.rb
override.rb
override.rb:11:in `alias_method': nil is not a symbol (TypeError)
        from override.rb:11:in `restore'
        from override.rb:26

4.instance method adding another instance method to the class

5.rdoc, link to another class instance method

6. "ruby myscript.rb" Works, "./myscript.rb" Doesn't

7. including instance methods and setting an instance varia

8. including instance methods and setting an instance variable



Return to ruby

 

Who is online

Users browsing this forum: No registered users and 70 guest