changeset 6:a50d2fac49ce

Add some experiments of what different objects are and what functions they have
author IBBoard <dev@ibboard.co.uk>
date Mon, 02 Jan 2017 20:45:34 +0000
parents 2b423d86da51
children b8f4577db289
files 1-Ruby/object-all-things-2-irb.output 1-Ruby/object-all-things-2-ruby.output 1-Ruby/object-all-things-2.rb
diffstat 3 files changed, 1163 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/1-Ruby/object-all-things-2-irb.output	Mon Jan 02 20:45:34 2017 +0000
@@ -0,0 +1,583 @@
+object-all-things-2.rb(main):001:0> #! /usr/bin/env ruby
+object-all-things-2.rb(main):002:0* 
+object-all-things-2.rb(main):003:0* objects = [ 4, 3.14, 'Pi', 'π']
+=> [4, 3.14, "Pi", "π"]
+object-all-things-2.rb(main):004:0> objects.each { |obj|
+object-all-things-2.rb(main):005:1* 	puts "#{obj} (#{obj.class})"
+object-all-things-2.rb(main):006:1> 	obj.methods.each { |method| puts "    #{method}" }
+object-all-things-2.rb(main):007:1> }
+4 (Fixnum)
+    to_s
+    inspect
+    -@
+    +
+    -
+    *
+    /
+    div
+    %
+    modulo
+    divmod
+    fdiv
+    **
+    abs
+    magnitude
+    ==
+    ===
+    <=>
+    >
+    >=
+    <
+    <=
+    ~
+    &
+    |
+    ^
+    []
+    <<
+    >>
+    to_f
+    size
+    bit_length
+    zero?
+    odd?
+    even?
+    succ
+    integer?
+    upto
+    downto
+    times
+    next
+    pred
+    chr
+    ord
+    to_i
+    to_int
+    floor
+    ceil
+    truncate
+    round
+    gcd
+    lcm
+    gcdlcm
+    numerator
+    denominator
+    to_r
+    rationalize
+    singleton_method_added
+    coerce
+    i
+    +@
+    eql?
+    remainder
+    real?
+    nonzero?
+    step
+    quo
+    to_c
+    real
+    imaginary
+    imag
+    abs2
+    arg
+    angle
+    phase
+    rectangular
+    rect
+    polar
+    conjugate
+    conj
+    between?
+    nil?
+    =~
+    !~
+    hash
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    freeze
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+3.14 (Float)
+    to_s
+    inspect
+    coerce
+    -@
+    +
+    -
+    *
+    /
+    quo
+    fdiv
+    %
+    modulo
+    divmod
+    **
+    ==
+    ===
+    <=>
+    >
+    >=
+    <
+    <=
+    eql?
+    hash
+    to_f
+    abs
+    magnitude
+    zero?
+    to_i
+    to_int
+    floor
+    ceil
+    round
+    truncate
+    nan?
+    infinite?
+    finite?
+    numerator
+    denominator
+    to_r
+    rationalize
+    arg
+    angle
+    phase
+    singleton_method_added
+    i
+    +@
+    div
+    remainder
+    real?
+    integer?
+    nonzero?
+    step
+    to_c
+    real
+    imaginary
+    imag
+    abs2
+    rectangular
+    rect
+    polar
+    conjugate
+    conj
+    between?
+    nil?
+    =~
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    freeze
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+Pi (String)
+    <=>
+    ==
+    ===
+    eql?
+    hash
+    casecmp
+    +
+    *
+    %
+    []
+    []=
+    insert
+    length
+    size
+    bytesize
+    empty?
+    =~
+    match
+    succ
+    succ!
+    next
+    next!
+    upto
+    index
+    rindex
+    replace
+    clear
+    chr
+    getbyte
+    setbyte
+    byteslice
+    scrub
+    scrub!
+    freeze
+    to_i
+    to_f
+    to_s
+    to_str
+    inspect
+    dump
+    upcase
+    downcase
+    capitalize
+    swapcase
+    upcase!
+    downcase!
+    capitalize!
+    swapcase!
+    hex
+    oct
+    split
+    lines
+    bytes
+    chars
+    codepoints
+    reverse
+    reverse!
+    concat
+    <<
+    prepend
+    crypt
+    intern
+    to_sym
+    ord
+    include?
+    start_with?
+    end_with?
+    scan
+    ljust
+    rjust
+    center
+    sub
+    gsub
+    chop
+    chomp
+    strip
+    lstrip
+    rstrip
+    sub!
+    gsub!
+    chop!
+    chomp!
+    strip!
+    lstrip!
+    rstrip!
+    tr
+    tr_s
+    delete
+    squeeze
+    count
+    tr!
+    tr_s!
+    delete!
+    squeeze!
+    each_line
+    each_byte
+    each_char
+    each_codepoint
+    sum
+    slice
+    slice!
+    partition
+    rpartition
+    encoding
+    force_encoding
+    b
+    valid_encoding?
+    ascii_only?
+    unpack
+    encode
+    encode!
+    to_r
+    to_c
+    >
+    >=
+    <
+    <=
+    between?
+    nil?
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+π (String)
+    <=>
+    ==
+    ===
+    eql?
+    hash
+    casecmp
+    +
+    *
+    %
+    []
+    []=
+    insert
+    length
+    size
+    bytesize
+    empty?
+    =~
+    match
+    succ
+    succ!
+    next
+    next!
+    upto
+    index
+    rindex
+    replace
+    clear
+    chr
+    getbyte
+    setbyte
+    byteslice
+    scrub
+    scrub!
+    freeze
+    to_i
+    to_f
+    to_s
+    to_str
+    inspect
+    dump
+    upcase
+    downcase
+    capitalize
+    swapcase
+    upcase!
+    downcase!
+    capitalize!
+    swapcase!
+    hex
+    oct
+    split
+    lines
+    bytes
+    chars
+    codepoints
+    reverse
+    reverse!
+    concat
+    <<
+    prepend
+    crypt
+    intern
+    to_sym
+    ord
+    include?
+    start_with?
+    end_with?
+    scan
+    ljust
+    rjust
+    center
+    sub
+    gsub
+    chop
+    chomp
+    strip
+    lstrip
+    rstrip
+    sub!
+    gsub!
+    chop!
+    chomp!
+    strip!
+    lstrip!
+    rstrip!
+    tr
+    tr_s
+    delete
+    squeeze
+    count
+    tr!
+    tr_s!
+    delete!
+    squeeze!
+    each_line
+    each_byte
+    each_char
+    each_codepoint
+    sum
+    slice
+    slice!
+    partition
+    rpartition
+    encoding
+    force_encoding
+    b
+    valid_encoding?
+    ascii_only?
+    unpack
+    encode
+    encode!
+    to_r
+    to_c
+    >
+    >=
+    <
+    <=
+    between?
+    nil?
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+=> [4, 3.14, "Pi", "π"]
+object-all-things-2.rb(main):008:0> 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/1-Ruby/object-all-things-2-ruby.output	Mon Jan 02 20:45:34 2017 +0000
@@ -0,0 +1,573 @@
+4 (Fixnum)
+    to_s
+    inspect
+    -@
+    +
+    -
+    *
+    /
+    div
+    %
+    modulo
+    divmod
+    fdiv
+    **
+    abs
+    magnitude
+    ==
+    ===
+    <=>
+    >
+    >=
+    <
+    <=
+    ~
+    &
+    |
+    ^
+    []
+    <<
+    >>
+    to_f
+    size
+    bit_length
+    zero?
+    odd?
+    even?
+    succ
+    integer?
+    upto
+    downto
+    times
+    next
+    pred
+    chr
+    ord
+    to_i
+    to_int
+    floor
+    ceil
+    truncate
+    round
+    gcd
+    lcm
+    gcdlcm
+    numerator
+    denominator
+    to_r
+    rationalize
+    singleton_method_added
+    coerce
+    i
+    +@
+    eql?
+    remainder
+    real?
+    nonzero?
+    step
+    quo
+    to_c
+    real
+    imaginary
+    imag
+    abs2
+    arg
+    angle
+    phase
+    rectangular
+    rect
+    polar
+    conjugate
+    conj
+    between?
+    nil?
+    =~
+    !~
+    hash
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    freeze
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+3.14 (Float)
+    to_s
+    inspect
+    coerce
+    -@
+    +
+    -
+    *
+    /
+    quo
+    fdiv
+    %
+    modulo
+    divmod
+    **
+    ==
+    ===
+    <=>
+    >
+    >=
+    <
+    <=
+    eql?
+    hash
+    to_f
+    abs
+    magnitude
+    zero?
+    to_i
+    to_int
+    floor
+    ceil
+    round
+    truncate
+    nan?
+    infinite?
+    finite?
+    numerator
+    denominator
+    to_r
+    rationalize
+    arg
+    angle
+    phase
+    singleton_method_added
+    i
+    +@
+    div
+    remainder
+    real?
+    integer?
+    nonzero?
+    step
+    to_c
+    real
+    imaginary
+    imag
+    abs2
+    rectangular
+    rect
+    polar
+    conjugate
+    conj
+    between?
+    nil?
+    =~
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    freeze
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+Pi (String)
+    <=>
+    ==
+    ===
+    eql?
+    hash
+    casecmp
+    +
+    *
+    %
+    []
+    []=
+    insert
+    length
+    size
+    bytesize
+    empty?
+    =~
+    match
+    succ
+    succ!
+    next
+    next!
+    upto
+    index
+    rindex
+    replace
+    clear
+    chr
+    getbyte
+    setbyte
+    byteslice
+    scrub
+    scrub!
+    freeze
+    to_i
+    to_f
+    to_s
+    to_str
+    inspect
+    dump
+    upcase
+    downcase
+    capitalize
+    swapcase
+    upcase!
+    downcase!
+    capitalize!
+    swapcase!
+    hex
+    oct
+    split
+    lines
+    bytes
+    chars
+    codepoints
+    reverse
+    reverse!
+    concat
+    <<
+    prepend
+    crypt
+    intern
+    to_sym
+    ord
+    include?
+    start_with?
+    end_with?
+    scan
+    ljust
+    rjust
+    center
+    sub
+    gsub
+    chop
+    chomp
+    strip
+    lstrip
+    rstrip
+    sub!
+    gsub!
+    chop!
+    chomp!
+    strip!
+    lstrip!
+    rstrip!
+    tr
+    tr_s
+    delete
+    squeeze
+    count
+    tr!
+    tr_s!
+    delete!
+    squeeze!
+    each_line
+    each_byte
+    each_char
+    each_codepoint
+    sum
+    slice
+    slice!
+    partition
+    rpartition
+    encoding
+    force_encoding
+    b
+    valid_encoding?
+    ascii_only?
+    unpack
+    encode
+    encode!
+    to_r
+    to_c
+    >
+    >=
+    <
+    <=
+    between?
+    nil?
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
+π (String)
+    <=>
+    ==
+    ===
+    eql?
+    hash
+    casecmp
+    +
+    *
+    %
+    []
+    []=
+    insert
+    length
+    size
+    bytesize
+    empty?
+    =~
+    match
+    succ
+    succ!
+    next
+    next!
+    upto
+    index
+    rindex
+    replace
+    clear
+    chr
+    getbyte
+    setbyte
+    byteslice
+    scrub
+    scrub!
+    freeze
+    to_i
+    to_f
+    to_s
+    to_str
+    inspect
+    dump
+    upcase
+    downcase
+    capitalize
+    swapcase
+    upcase!
+    downcase!
+    capitalize!
+    swapcase!
+    hex
+    oct
+    split
+    lines
+    bytes
+    chars
+    codepoints
+    reverse
+    reverse!
+    concat
+    <<
+    prepend
+    crypt
+    intern
+    to_sym
+    ord
+    include?
+    start_with?
+    end_with?
+    scan
+    ljust
+    rjust
+    center
+    sub
+    gsub
+    chop
+    chomp
+    strip
+    lstrip
+    rstrip
+    sub!
+    gsub!
+    chop!
+    chomp!
+    strip!
+    lstrip!
+    rstrip!
+    tr
+    tr_s
+    delete
+    squeeze
+    count
+    tr!
+    tr_s!
+    delete!
+    squeeze!
+    each_line
+    each_byte
+    each_char
+    each_codepoint
+    sum
+    slice
+    slice!
+    partition
+    rpartition
+    encoding
+    force_encoding
+    b
+    valid_encoding?
+    ascii_only?
+    unpack
+    encode
+    encode!
+    to_r
+    to_c
+    >
+    >=
+    <
+    <=
+    between?
+    nil?
+    !~
+    class
+    singleton_class
+    clone
+    dup
+    taint
+    tainted?
+    untaint
+    untrust
+    untrusted?
+    trust
+    frozen?
+    methods
+    singleton_methods
+    protected_methods
+    private_methods
+    public_methods
+    instance_variables
+    instance_variable_get
+    instance_variable_set
+    instance_variable_defined?
+    remove_instance_variable
+    instance_of?
+    kind_of?
+    is_a?
+    tap
+    send
+    public_send
+    respond_to?
+    extend
+    display
+    method
+    public_method
+    singleton_method
+    define_singleton_method
+    object_id
+    to_enum
+    enum_for
+    equal?
+    !
+    !=
+    instance_eval
+    instance_exec
+    __send__
+    __id__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/1-Ruby/object-all-things-2.rb	Mon Jan 02 20:45:34 2017 +0000
@@ -0,0 +1,7 @@
+#! /usr/bin/env ruby
+
+objects = [ 4, 3.14, 'Pi', 'π']
+objects.each { |obj|
+	puts "#{obj} (#{obj.class})"
+	obj.methods.each { |method| puts "    #{method}" }
+}