Class: ChemScanner::ChemDraw::Bond
- Defined in:
- lib/chem_scanner/chem_draw/node/bond.rb
Overview
CDX Bond parser
Constant Summary
Constants included from BaseValue
ChemScanner::ChemDraw::BaseValue::ARROW_NOGO_CROSS, ChemScanner::ChemDraw::BaseValue::CDXML_ARROW_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_ATOM_EXTERNAL_CONNECTION_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_CDX_POINT, ChemScanner::ChemDraw::BaseValue::CDXML_GRAPHIC_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_LINE_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_NODE_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_ORBITAL_TYPE, ChemScanner::ChemDraw::BaseValue::CDXML_OVAL_TYPE, ChemScanner::ChemDraw::BaseValue::TEXT_ATTRIBUTES
Instance Attribute Summary collapse
-
#begin_id ⇒ Object
Returns the value of attribute begin_id.
-
#color ⇒ Object
Returns the value of attribute color.
-
#end_id ⇒ Object
Returns the value of attribute end_id.
-
#order ⇒ Object
Returns the value of attribute order.
-
#stereo ⇒ Object
Returns the value of attribute stereo.
Attributes inherited from BaseNode
#id, #parser, #parser_type, #polygon
Instance Method Summary collapse
- #bond_display(tag, data) ⇒ Object
- #bond_order(val) ⇒ Object
- #end_points ⇒ Object
- #has_endpoint?(id) ⇒ Boolean
-
#initialize(parser, parser_type, id) ⇒ Bond
constructor
A new instance of Bond.
- #other_endpoint(endpoint) ⇒ Object
- #parse_node(tag, _id, data) ⇒ Object
- #replace_endpoint(endpoint, new_point) ⇒ Object
Methods inherited from BaseNode
#assign_center, #bounding_box, #cdx_read, #cdxml_read, #center_x, #center_y, #get_tempid, #post_parse_node, #pre_parse_node, #read, #set_cdx, #set_cdxml
Methods included from BaseValue
#binary_chunks, #cdx_styles, #cdx_text, #cdxml_text, #do_unhandled, #point_2d, #point_3d, #polygon_from_bb, #read_bounding_box, #read_ids, #read_int, #read_type, #read_value
Constructor Details
#initialize(parser, parser_type, id) ⇒ Bond
Returns a new instance of Bond.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 45 def initialize(parser, parser_type, id) super(parser, parser_type, id) @begin_id = nil @end_id = nil @stereo = 0 @order = 1 @color = 0 end |
Instance Attribute Details
#begin_id ⇒ Object
Returns the value of attribute begin_id.
43 44 45 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 43 def begin_id @begin_id end |
#color ⇒ Object
Returns the value of attribute color.
43 44 45 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 43 def color @color end |
#end_id ⇒ Object
Returns the value of attribute end_id.
43 44 45 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 43 def end_id @end_id end |
#order ⇒ Object
Returns the value of attribute order.
43 44 45 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 43 def order @order end |
#stereo ⇒ Object
Returns the value of attribute stereo.
43 44 45 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 43 def stereo @stereo end |
Instance Method Details
#bond_display(tag, data) ⇒ Object
73 74 75 76 77 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 73 def bond_display(tag, data) return read_value(tag, data) if @parser_type == "cdx" CDXML_BOND_DISPLAY[data.text] end |
#bond_order(val) ⇒ Object
67 68 69 70 71 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 67 def bond_order(val) return val if @parser_type == "cdxml" CDX_BOND_ORDER[val] || 0 end |
#end_points ⇒ Object
79 80 81 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 79 def end_points [@begin_id, @end_id] end |
#has_endpoint?(id) ⇒ Boolean
95 96 97 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 95 def has_endpoint?(id) [@begin_id, @end_id].include?(id) end |
#other_endpoint(endpoint) ⇒ Object
91 92 93 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 91 def other_endpoint(endpoint) endpoint == @begin_id ? @end_id : @begin_id end |
#parse_node(tag, _id, data) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 56 def parse_node(tag, _id, data) case @props_ref[tag] when "Bond_Begin" then @begin_id = read_value(tag, data) when "Bond_End" then @end_id = read_value(tag, data) when "Bond_Order" then @order = bond_order(read_value(tag, data)) when "Bond_Display" then @stereo = bond_display(tag, data) when "ForegroundColor" then @color = read_value(tag, data) else do_unhandled(tag) end end |
#replace_endpoint(endpoint, new_point) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/chem_scanner/chem_draw/node/bond.rb', line 83 def replace_endpoint(endpoint, new_point) if @begin_id == endpoint @begin_id = new_point elsif @end_id == endpoint @end_id = new_point end end |