Class: Microstation::TS::Attribute
- Inherits:
-
Object
- Object
- Microstation::TS::Attribute
- Defined in:
- lib/microstation/ts/attribute.rb
Constant Summary collapse
- TYPES =
msdTagTypeCharacter 1 (&H1) msdTagTypeShortInteger 2 (&H2) msdTagTypeLongInteger 3 (&H3) msdTagTypeDouble 4 (&H4) msdTagTypeBinary 5 (&H5)
{ 1 => String, 2 => Integer, 3 => Integer, 4 => Float, # 5 => Binary }
- RUBY_TO_MS =
TYPES.invert
Instance Attribute Summary collapse
-
#ole_obj ⇒ Object
readonly
Returns the value of attribute ole_obj.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #att_type ⇒ Object
- #attrib_options ⇒ Object
- #close ⇒ Object
- #constant=(constant) ⇒ Object
- #constant? ⇒ Boolean
- #default ⇒ Object
- #default=(val) ⇒ Object
- #has_default? ⇒ Boolean
- #hidden=(hidden) ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(ole, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #name ⇒ Object
- #name=(val) ⇒ Object
- #options_for_attribute ⇒ Object
- #prompt ⇒ Object
- #prompt=(val) ⇒ Object
- #tagset ⇒ Object
- #tagset_name ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(ole, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
47 48 49 50 |
# File 'lib/microstation/ts/attribute.rb', line 47 def initialize(ole, = {}) @ole_obj = ole @definition = [:definer] end |
Instance Attribute Details
#ole_obj ⇒ Object (readonly)
Returns the value of attribute ole_obj.
6 7 8 |
# File 'lib/microstation/ts/attribute.rb', line 6 def ole_obj @ole_obj end |
Class Method Details
.tag_type(type) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/microstation/ts/attribute.rb', line 24 def self.tag_type(type) if type.class == Symbol ruby_type = case type when :char String when :int Integer when :float Float else :char end else ruby_type = type end RUBY_TO_MS[ruby_type] end |
Instance Method Details
#==(other) ⇒ Object
132 133 134 |
# File 'lib/microstation/ts/attribute.rb', line 132 def ==(other) @ole_obj.Name == other.ole_obj.Name && @ole_obj.TagSetName == other.ole_obj.TagSetName && @ole_obj.TagType == other.ole_obj.TagType end |
#att_type ⇒ Object
43 44 45 |
# File 'lib/microstation/ts/attribute.rb', line 43 def att_type TYPES[type] end |
#attrib_options ⇒ Object
121 122 123 124 125 126 |
# File 'lib/microstation/ts/attribute.rb', line 121 def = {} [:default] = default_value if has_default? [:readonly] = true if constant? end |
#close ⇒ Object
52 53 54 |
# File 'lib/microstation/ts/attribute.rb', line 52 def close @ole_obj = nil end |
#constant=(constant) ⇒ Object
84 85 86 87 |
# File 'lib/microstation/ts/attribute.rb', line 84 def constant=(constant) bool = constant ? true : false @ole_obj.IsConstant = bool end |
#constant? ⇒ Boolean
80 81 82 |
# File 'lib/microstation/ts/attribute.rb', line 80 def constant? @ole_obj.IsConstant end |
#default ⇒ Object
89 90 91 |
# File 'lib/microstation/ts/attribute.rb', line 89 def default @ole_obj.DefaultValue end |
#default=(val) ⇒ Object
93 94 95 |
# File 'lib/microstation/ts/attribute.rb', line 93 def default=(val) @ole_obj.DefaultValue = val end |
#has_default? ⇒ Boolean
97 98 99 |
# File 'lib/microstation/ts/attribute.rb', line 97 def has_default? !!default end |
#hidden=(hidden) ⇒ Object
105 106 107 108 |
# File 'lib/microstation/ts/attribute.rb', line 105 def hidden=(hidden) bool = hidden ? true :false @ole_obj.IsHidden = bool end |
#hidden? ⇒ Boolean
101 102 103 |
# File 'lib/microstation/ts/attribute.rb', line 101 def hidden? @ole_obj.IsHidden end |
#name ⇒ Object
60 61 62 |
# File 'lib/microstation/ts/attribute.rb', line 60 def name @ole_obj.name end |
#name=(val) ⇒ Object
64 65 66 |
# File 'lib/microstation/ts/attribute.rb', line 64 def name=(val) @ole_obj.Name = val end |
#options_for_attribute ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/microstation/ts/attribute.rb', line 68 def = {} [:is_hidden] = true if hidden? [:prompt] = prompt if prompt [:default] = default_value [:readonly] = true if constant? end |
#prompt ⇒ Object
109 110 111 |
# File 'lib/microstation/ts/attribute.rb', line 109 def prompt @ole_obj.Prompt end |
#prompt=(val) ⇒ Object
113 114 115 |
# File 'lib/microstation/ts/attribute.rb', line 113 def prompt=(val) @ole_obj.Prompt = val end |
#tagset ⇒ Object
56 57 58 |
# File 'lib/microstation/ts/attribute.rb', line 56 def @definition. if definition end |
#tagset_name ⇒ Object
128 129 130 |
# File 'lib/microstation/ts/attribute.rb', line 128 def @ole_obj.TagSetName end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/microstation/ts/attribute.rb', line 76 def to_s "TagDefinition: #{name}" end |
#type ⇒ Object
117 118 119 |
# File 'lib/microstation/ts/attribute.rb', line 117 def type TYPES[@ole_obj.TagType] end |