Class: IbRubyProxy::Server::IbRubyClassSourceGenerator
- Inherits:
-
Object
- Object
- IbRubyProxy::Server::IbRubyClassSourceGenerator
- Includes:
- Util::StringUtils
- Defined in:
- lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb
Overview
Given a value object class from Interactive Broker API, this generator can build Ruby source code for:
-
A ruby class to manipulate the same class in Ruby
-
An extension to the original Java class for converting instances into Ruby
Instance Attribute Summary collapse
-
#ib_class ⇒ Object
readonly
Returns the value of attribute ib_class.
-
#namespace_list ⇒ Object
readonly
Returns the value of attribute namespace_list.
Instance Method Summary collapse
-
#ib_class_extension_source ⇒ String
Source for a ruby class that extends the original IB Java class with a
to_ruby
method, to convert Java Ib objects into their Ruby counterparts generated in #ruby_class_source. -
#initialize(ib_class, namespace: 'IbRubyProxy::Client::Ib') ⇒ IbRubyClassSourceGenerator
constructor
A new instance of IbRubyClassSourceGenerator.
-
#ruby_class_source ⇒ String
Source for a ruby class translates into Ruby the Java properties of the target ib class.
Methods included from Util::StringUtils
#to_camel_case, #to_underscore
Constructor Details
#initialize(ib_class, namespace: 'IbRubyProxy::Client::Ib') ⇒ IbRubyClassSourceGenerator
Returns a new instance of IbRubyClassSourceGenerator.
18 19 20 21 |
# File 'lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb', line 18 def initialize(ib_class, namespace: 'IbRubyProxy::Client::Ib') @ib_class = Reflection::IbClass.new(ib_class) @namespace_list = namespace.split('::') end |
Instance Attribute Details
#ib_class ⇒ Object (readonly)
Returns the value of attribute ib_class.
11 12 13 |
# File 'lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb', line 11 def ib_class @ib_class end |
#namespace_list ⇒ Object (readonly)
Returns the value of attribute namespace_list.
11 12 13 |
# File 'lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb', line 11 def namespace_list @namespace_list end |
Instance Method Details
#ib_class_extension_source ⇒ String
Source for a ruby class that extends the original IB Java class with a to_ruby
method, to convert Java Ib objects into their Ruby counterparts generated in #ruby_class_source
43 44 45 46 47 48 49 |
# File 'lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb', line 43 def ib_class_extension_source <<-RUBY #{header} #{generate_ib_class_extension} RUBY end |
#ruby_class_source ⇒ String
Source for a ruby class translates into Ruby the Java properties of the target ib class.
It generates a Struct with the list of properties, that admits a keyword-based constructor, and that includes a to_ib
method for converting the ruby back into its original Java counterpart.
31 32 33 34 35 36 37 |
# File 'lib/ib_ruby_proxy/server/ib_ruby_class_source_generator.rb', line 31 def ruby_class_source <<-RUBY #{header} #{generate_ruby_class} RUBY end |